"Be sure that the program correctly calculates the factorial of the number 0." It does what codegym wants, I got no clue.
"The factorial method must return a string representation of the factorial of the number passed as an argument." ther is no specific format output string so I assumed It's "4!=24", tried just result, anyway I can't waste more time , any tips welcome, thanx.
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
double i = 1;
Double sum = new Double(1);
if (n < 0) return "0";
while (i <= n) {
sum *= i;
i++;
//System.out.println(sum);
}
return n + "!=" + sum.longValue();
}
}