It works perfectly on my machine. Have no idea why the validator doesn't accept it/
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";
}
if (n == 0) {
return String.valueOf(1);
}
double a = n * Double.parseDouble(factorial(n - 1));
return String.valueOf(a);
}
}