Factorial in Java

public class First {

void fact(int num){
int temp=1;
for(int i=num;i>0;i--){
temp=temp*i;
}
System.out.println(temp);
}

public static void main(String[] args) {
new First().fact(5);
}

}

No comments: