摘要:
A Pythagorean triplet is a set of three natural numbers,abc, for which,a2+b2=c2For example, 32+ 42= 9 + 16 = 25 = 52.There exists exactly one Pythagorean triplet for whicha+b+c= 1000.Find the productabc.#include#include#include#include#include#includevoid show(){ int a,b,c; for(a=1; a<333; a++... 阅读全文
摘要:
Let d(n) be defined as the sum of proper divisors ofn(numbers less thannwhich divide evenly inton).If d(a) =band d(b) =a, whereab, thenaandbare an amicable pair and each ofaandbare called amicable numbers.For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110; therefo 阅读全文
摘要:
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 9199.Find the largest palindrome made from the product of two 3-digit numbers.#include
#include
#include
#include
#include
#include bool palindromic(int n) //判断一个整数是否为回文数
{... 阅读全文
摘要:
The prime factors of 13195 are 5, 7, 13 and 29.What is the largest prime factor of the number 600851475143 ?#include
#include
#include
#include
#include
#include #define N 600851475143 bool prim(int n)
{ int i; for(i=2; i*i<=n; i++) { if(n%i==0) return false; } return true;
} int main()... 阅读全文
摘要:
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.Find the sum of all the primes below two million.#include
#include
#include
#include
#include
#include #define N 2000000 bool prim(int n)
{ int i; for(i=2; i*i<=n; i++) { if(n%i==0) return false; } return true;
} int main()
{ int i;
... 阅读全文