欧拉项目 Problem 12 of What is the value of the first triangle number to have over five hundred divisors
来源:互联网 发布:暴风影音mac版怎么用 编辑:程序博客网 时间:2024/05/16 11:49
The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be:
1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...
Let us list the factors of the first seven triangle numbers:
1: 1
3: 1,3
6: 1,2,3,6
10: 1,2,5,10
15: 1,3,5,15
21: 1,3,7,21
28: 1,2,4,7,14,28
We can see that 28 is the first triangle number to have over five divisors.
What is the value of the first triangle number to have over five hundred divisors?
public class TriangleNumbers {public static void main(String args[]){Long l1=System.currentTimeMillis();for(int i=1;i<1000000;i++){if(reTriangle(numTriangle(i))>500){System.out.println(numTriangle(i));break;}}Long l2=System.currentTimeMillis();System.out.println("need time:"+(l2-l1));}public static int numTriangle(int n){int sum=0;for(int i=1;i<=n;i++){sum+=i;}return sum;}public static int reTriangle(int n){int total=0;for(int i=1;i<=n;i++){if(n%i==0){total++;}}return total;}}
76576500need time:1116423
Answer:
76576500- 欧拉项目 Problem 12 of What is the value of the first triangle number to have over five hundred divisors
- Problem 16 - What is the sum of the digits of the number 2^1000?
- 76 What is the effect of increasing the value of the ASM_POWER_LIMIT parameter? A. The number of DBW
- Problem 7 of What is the 10 001st prime number?
- 欧拉项目 Problem 25 of in the Fibonacci sequence to contain 1000 digits
- The value of first company
- What is the use of "?
- the first is over
- What is the purpose of the USB?
- Problem 11 of What is the greatest product of four adjacent numbers
- What Is the Purpose of This Book?
- What is the key of Data Assimilation?
- what is the use of truncate command
- What is the truth of life???
- what is the purpose of __ASSEMBLY__?
- What is The Rule of Three?
- What is the purpose of /etc/default?
- What is The Rule of Three?
- 定义一个大对象,直接放入OLD区(对象占用的对内存占总的设置的内存一半以上),容易发生FGC
- 基本知识(一) OTA的介绍
- PCM数据合成WAV文件
- List模板类实现回文判断
- VIM 多文件查找替换
- 欧拉项目 Problem 12 of What is the value of the first triangle number to have over five hundred divisors
- VC里设置系统时间
- navigation
- Oracle 备份和还原
- myeclipse jvm设置
- 毕业后的五年拉开大家差距的原因
- Grails_数据库逆向工程插件 db-reverse-engineer
- IP正则表达式
- iphone--FMDatabase 使用