FACTORIAL PROGRAM IN JAVA
import java.util.Scanner;
public class factorialProgram {
public static void main (String [] args){
Scanner scan = new Scanner(System.in);
System.out.println("ENTER THE NUMBER TO CALCULATE THE FACTORIAL OF THE NUMBER");
int sum =1;
int n = scan.nextInt();
for(int i = n ; i>0 ; i-- ){
sum*=i;
}
System.out.println("THE FACTORIAL OF THA GIVEN NUMBER YOU ENTERED IS:"+sum);
}
}
Comments
Post a Comment