//Write a program to find factorial of a given number using for loop

 

public class CWH_PS5 {

public static void main(String[] args) {

int i, fact = 1;
int n = 5;
for( i = 1; i<=n; i++){
fact = fact*i
;

}
System.
out.println(fact);
}
}

//output
120 Process finished with exit code 0

Post a Comment

0 Comments