欧拉项目 第20题 Factorial digit sum
来源:互联网 发布:个性挂历制作软件 编辑:程序博客网 时间:2024/06/16 02:21
n! means n × (n − 1) × ... × 3 × 2 × 1
For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800,
and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.
Find the sum of the digits in the number 100!
求100!个位数和。
public static void main(String[] args) { long start = System.currentTimeMillis(); BigInteger x = BigInteger.ONE; for(Integer i=2;i<100;i++) { x = x.multiply(BigInteger.valueOf(i));// if(x.divideAndRemainder(new BigInteger("10"))[1].compareTo(new BigInteger("0")) == 0) {// x = x.divide(new BigInteger("10"));// } } Integer sum = 0; String sx = x.toString().replaceAll("0", ""); for(int i=0;i<sx.length();i++) { sum += Integer.parseInt(sx.substring(i, i + 1)); //<span style="font-family: monospace; font-size: 12.87px; white-space: pre-wrap;"> Character.getNumericValue(sx.charAt(i));</span> } System.out.println(sum); System.out.println(System.currentTimeMillis() - start); }
0 0
- 欧拉项目 第20题 Factorial digit sum
- 欧拉项目第16题 Power digit sum
- Problem 20:Factorial digit sum
- PE 20 Factorial digit sum
- Project Euler 题解 #20 Factorial digit sum
- projecteuler---->problem=20----Factorial digit sum
- Project Euler:Problem 20 Factorial digit sum
- 20 Factorial digit sum - Project Euler
- Project Euler Problem 20 Factorial digit sum
- project euler 20 Factorial digit sum
- [projecteuler]Factorial digit sum
- ProjectEuler-Problem20-Factorial digit sum
- 欧拉项目第13题 Large sum
- 欧拉项目第18题Maximum path sum I
- Project Euler 20 Factorial digit sum(大数乘法)
- Problem 20 Factorial digit sum (阶乘数和)
- Matlab 编程 Project Euler Problem 20 Factorial digit sum
- 欧拉工程第25题:1000-digit Fibonacci number
- 灵活的 switch
- 从一个算法题学到的
- iOS内存管理-所有权修饰符:__strong, __weak/__unsafe_unretained, __autoreleasing
- .NET跨平台之旅:corehost 是如何加载 coreclr 的 企
- Rxjava学习
- 欧拉项目 第20题 Factorial digit sum
- tag_BIGINT
- Activity recreate 后停留在onPause()状态
- 【追求进步】斐波那契数列
- 1、单目相机内参标定(camera_calibration_internal)
- C/C++—— 写一个函数,它的参数为指向函数的指针,返回类型也为指向函数的指针
- jQuery常用事件处理
- hashMap最久最大遍历
- iOS CocoaPods安装和使用图解