WAP to find the factorial of a given number
import java.util.*;
class CT3 {
public static void main(String[] args) {
int n;
int i = 1;
int fact = 1;
Scanner sc = new Scanner(System.in);
System.out.print("Enter a number : ");
n = sc.nextInt();
while(i<=n) {
fact *= i;
i++;
}
System.out.println("Here is the factorial : " + fact);
}
}
Copy Code