Wrong Answer

2j1ejyu Reply 6 years 8 weeks ago
import java.util.*; public class Main{ public static void main(String[] args){ Scanner input = new Scanner(System.in); Main obj = new Main(); int testcase = input.nextInt(); int[] i = new int[testcase]; for (int j=0; j<testcase; j++){ i[j] = input.nextInt(); } for (int j=0; j<testcase; j++){ double sum = 1; for(int k=1; k<=i[j]; k++){ sum += 1/obj.factorial(k); } sum = Math.floor(sum*1000000)/1000000.0; System.out.printf("%.6f\n", sum); } } public double factorial(int i){ int factorial = 1; for (int j=1; j<=i; j++){ factorial *= j; } return factorial; } } 왜 틀린건가요?
onacloud Reply 6 years 8 weeks ago
1 100 을 입력해 보세요