如果我的代码有任何问题,有人可以抓住吗?我正在尝试计算执行此阶乘并将其转换为秒所需的时间,但它似乎打印出错误的值。谢谢!!
long startTime = System.nanoTime();
BigInteger factorial_minute = doFactorial(50000);
long endTime = System.nanoTime();
String factorial_minute_str = factorial_minute.toString();
System.out.println("Largest n! in one minute = " + factorial_minute);
System.out.println("n! in one minute Amount of Digits: " + factorial_minute_str.length()); // Print the length also
System.out.println("Total execution time: " + (int)((endTime - startTime)/1000000000 + " seconds") );
输出是
总执行时间:4秒
编辑,我将其更改为 1000000000,但似乎输出仍然错误。