Java 代码实现 1 到 100 连乘,结果小于特定值即停止
public class Main { public static void main(String[] args) { long result = 1; for (int i = 1; i <= 100; i++) { result *= i; if (result < 10000000000000000000000000000000099999999999999999999999999999999999999999999999999999999999999999990000000000000000L) { System.out.println('Result is less than the threshold: ' + result); break; } } } }
原文地址: http://www.cveoy.top/t/topic/mf5I 著作权归作者所有。请勿转载和采集!