FACTORIAL (JAVA)
import
java.util.Scanner;
class
Factorial {
public static void main(String
args[]){
int i,fact=1,
number;
Scanner
sc = new Scanner(System.in);
System.out.print("Enter
the number: ");
number
= sc.nextInt();
for(i=1;i<=number;i++){
fact=fact*i;
}
System.out.println("Factorial
of "+number+" is: "+fact);
}
}
Comments
Post a Comment
If you have any doubts, Feel free to Ask !