My code for factorials works fine up until n=13 where it then starts giving me the wrong answer. Does anyone know why?
public class Factorial {
public static void main(String[] args) {
System.out.println(factorial(13));
}
public static int factorial(int n) {
for (int i = n - 1; i >= 1; i--) {
n=n*i;
}
return n;
}
}