0

How to create factorial calculator

17th Sep 2018, 12:43 PM
TECHनिकल JHAPATE
TECHनिकल JHAPATE - avatar
3 ответов
+ 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); } }
18th Sep 2018, 8:23 AM
Sumit Programmer😎😎
Sumit Programmer😎😎 - avatar
17th Sep 2018, 7:55 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
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.
17th Sep 2018, 2:09 PM
hinanawi
hinanawi - avatar