问题描述:
145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.
Find the sum of all numbers which are equal to the sum of the factorial of their digits.
Note: as 1! = 1 and 2! = 2 are not sums they are not included.
解决问题:
public class Problem34 {
public static final int UP = 362880;
public static int jiecheng(int number){
int result = 1;
for(int i=2; i<=number; i++){
result *= i;
}
return result ;
}
public static int sum(){
int result = 0;
for(int i=11; i<UP; i++){
int value = 0;
int current = i;
while(current!=0){
value += jiecheng(current%10);
current = current/10;
}
if(value==i){
System.out.println(value);
result += value;
}
}
return result;
}
public static void main(String[] args){
System.out.println(sum());
}
}
分享到:
相关推荐
Computer Networking: A Top-Down Approach, 6th Edition Solutions to Review Questions and Problems Version Date: May 2012 ...This document contains the solutions to review questions ...Problem 1 There...
0-1-knapsack-problem-master (34).zip
C#,子集和问题(Subset Sum Problem)的算法与源代码 1 子集和问题(Subset Sum Problem) 给定一组非负整数和一个值和,确定给定集合中是否存在和等于给定和的子集。 示例: 输入:set[]={3,34,4,12,5,2},...
数值计算大作业
22.4 Hanging System Backup 34 22.5 Charging Data Problem 35 22.6 Alarm Function Related Problem 35 22.7 Hanging Command/Hanging IO Device 35 22.8 SPG Restart 36 22.9 SPG-OSS Connection problem 36 23. ...
void md5_compress(uint32 ihv[], const uint32 block[]) { uint32 a = ihv[0]; uint32 b = ihv[1]; uint32 c = ihv[2]; uint32 d = ihv[3]; ... MD5_STEP(FF, a, b, c, d, block[0], 0xd76aa478, 7);...
离线安装包,亲测可用
离线安装包,亲测可用
离线安装包,亲测可用
离线安装包
Problem Runtime Mem Usage Level 28毫秒( 93.73% ) 13.4 MB( 79.11% ) 简单 52毫秒( 94.00% ) 13.6 MB( 45.02% ) 中等的 36毫秒( 95.77% ) 13.7 MB( 73.48% ) 中等的 68毫秒( 88.56% ) ...
monographs are devoted to the subject [34, 26]. Since the TSP is NP-hard, polynomial-time approximation algorithms are usually studied. However, usually the approaches to the study of vehicle routing ...
Summary • Review Questions • Problem Set 34 Chapter 2 Evolution of the Major Programming Languages 39 2.1 Zuse’s Plankalkül 40 2.2 Minimal Hardware Programming: Pseudocodes 43 2.3 The IBM...
2.7.2 Formulation 2 for Column Design 34 2.8 Minimum Cost Cylindrical Tank Design 35 2.9 Design of Coil Springs 36 2.10 Minimum Weight Design of a Symmetric Three-Bar Truss 38 2.11 A General ...
34在排序数组中找到元素的第一个和最后一个位置.md 35-搜索插入位置.md 36-有效的数独.md 38计数与说.md 39-组合-sum.md 40-组合和-ii.md 第43章 第46章 47-置换-ii.md 第48章 第49章 5个最长回文子串.md 50...
34 5 92 关联 6 1249 7 142 8 33 9 153 10 80 11 128 12 102 13 199 14 200 15 11 16 209 17 73 18 78 19 46 20 22 21 56 22 238 23 15 24 560 25 253 26 289 27 17 参考 描述 代码 二维数组 DFS 遍历 二维数组 BFS ...
Chapter 34. Deep Learning for Classification of Dental Plaque Images Chapter 35. Multiscale Integration for Pattern Recognition in Neuroimaging Chapter 36. Game Theoretical Tools for Wing Design ...
解决方案 (6:18,奖金2:34)2个谷歌最近曾问过这个问题。 给定一个数字列表和一个数字k,则返回列表中是否有两个数字加起来等于k。 例如,给定[10, 15, 3, 7]和k为17 ,则由于10 + 7为17,因此返回true 。 奖励:您...
CHAPTER 34 - Random Models and Analyses for Chemical Graphs CHAPTER 35 - Randomized Graph Algorithms: Techniques and Analysis SECTION XI - Coping with NP-Completeness CHAPTER 36 - General Techniques ...
Wilson has added new material on interval graphs, the traveling salesman problem, bracing frameworks, shortest route problems, and coloring maps on surfaces. Most of the diagrams in the book have ...