Ray's playground

 

2011年3月10日

Project Euler Problem 12

摘要: The sequence of triangle numbers is generated by adding the natural numbers. So the 7thtriangle 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: 13: 1,36: 1,2,3,610: 1,2 阅读全文

posted @ 2011-03-10 21:19 Ray Z 阅读(196) 评论(0) 推荐(0) 编辑

Project Euler Problem 3

摘要: The prime factors of 13195 are 5, 7, 13 and 29.What is the largest prime factor of the number 600851475143 ?1#include<iostream>2usingnamespacestd;34longlongGetFirstFactor(longlongnum)5{6longlongroot=sqrt((longdouble)num);7for(longlongi=2;i<root;i++)8{9if(num%i==0)10{11returni;12}13}1415retu 阅读全文

posted @ 2011-03-10 20:35 Ray Z 阅读(171) 评论(0) 推荐(0) 编辑

导航