0
How to create factorial calculator
3 Antworten
+ 21
java one liner
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
int a=1;for(int c=new Scanner(System.in).nextInt(),b=1;b<c;a+=(a*b),b++);System.out.println(a);
}
}
+ 2
either that or...
https://code.sololearn.com/cqfl1nmGprm4/?ref=app
;)
0
have a variable "x" initialized to 1, then iterate from 2 to n (inclusive, n being the number you want to calculate the factorial of) and multiply x by each.