Computer Science, asked by niveditasingh03, 9 months ago

write a program to accept any value in main() method and find out the factorial in a function fact(). Display the factorial in main method.​

Answers

Answered by yash6699
1

Factorial Program using loop in java

class FactorialExample{

public static void main(String args[]){

int i,fact=1;

int number=5;//It is the number to calculate factorial.

for(i=1;i<=number;i++){

fact=fact*i;

}

System.out.println("Factorial of "+number+" is: "+fact);

Similar questions