You are viewing a single comment's thread. Return to all comments →
hello, I use java and try to solve it using a recursive method
public static void main(String[] args) { // TODO code application logic here Scanner in = new Scanner(System.in); int N = in.nextInt(); System.out.println(factorial(N)); } public static long factorial(int n){ if(n<0) return -1; else if(n==0) return 1; else return (long) n*factorial(n-1); }
the result is not correct, but I can't find the reason. Please help.
Seems like cookies are disabled on this browser, please enable them to open this website
Extra Long Factorials
You are viewing a single comment's thread. Return to all comments →
hello, I use java and try to solve it using a recursive method
the result is not correct, but I can't find the reason. Please help.