1 int num1 = 6;
2 int num2 = 1;
3 for(int a = 1; a<=num1; a++) {
4 num2 = num2 * a;
5 }
6 System.out.println(num2);
1// Factorial program using recursion
2public class FactorialRecursion
3{
4 public static void main(String[] args)
5 {
6 int factorial = 1;
7 int number = 6;
8 factorial = factorialFunction(number);
9 System.out.println("Factorial of " + number + " is : " + factorial);
10 }
11 static int factorialFunction(int num)
12 {
13 if(num == 0)
14 {
15 return 1;
16 }
17 else
18 {
19 return(num * factorialFunction(num - 1));
20 }
21 }
22}
1public class FactorialDemo
2{
3 public static void main(String[] args)
4 {
5 int number = 6, factorial = 1;
6 for(int a = 1; a <= number; a++)
7 {
8 factorial = factorial * a;
9 }
10 System.out.println("Factorial of " + number + " is : " + factorial);
11 }
12}
1double factorial = 1;
2double number=30;
3
4while ( numero!=0) {
5 factorial=factorial*number;
6 number--;
7}