smallfactorial problem

import java.util.Scanner;
class Small{
public static void main(String[] args){
Scanner scn=new Scanner(System.in);
int a[]=new int[5];
for(int i=0;i<=a.length-1;i++){
a[i]=scn.nextInt();
}
for(int i=1;i<=a.length-1;i++){
System.out.println(factorial(a[i]));

}}
static int factorial(int i){
if(i==1){
return 1;
}
else{
return i*factorial(i-1);
}}}

See this: SwyjAX - Online Java Compiler & Debugging Tool - Ideone.com

your code print wrong output for these test cases:

4
10
25
50
100

Your Output:

3628800
2076180480
0
0

and actual output should be:

3628800
15511210043330985984000000
30414093201713378043612608166064768844377641568960512000000000000
93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000

@sonu015 your code will give wrong answer for N>20.