Friday, December 01, 2006

Implement fatorial function

In Java:

public class factorial {
public static void main(String[] args){
int input = Integer.parseInt(args[0]);
int result= 1;
if(input == 0)
result=0;
while(input !=0){
result = result * input;
input --;
}
System.out.println(result);
}
}

No comments: