My solution seems to return and print the correct number regardless of test case, yet it still fails testing.

package com.codegym.task.task15.task1531;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
/*
Factorial
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int input = Integer.parseInt(reader.readLine());
reader.close();
System.out.println(factorial(input));
}
public static String factorial(int n) {
//write your code here
if (n < 0) {
return "" + 0;
}
int i, fact = 1;
for (i = 1; i <= n; i++) {
fact = fact*i;
}
return "" + fact;
}
}