various ways of doing factorial program java code example
Example: how to make factorial in java
class fact{
static int fac(int n){
int ans =1;
for(int i=1; i<=n; i++){
ans = ans*i;
}
return ans;
}
public static void main (String[] args){
int f = 5;
System.out.println(fac(f));
}
}