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

Popular posts from this blog

PROGRAM OF CALCULATING INTERSECTION OF TWO ARRAYS

JAVA PROGRAM TO CREATE A DATABASE (SAMPLE PICTURE IS GIVEN)

Craze for Fashion