
欧拉计划题解
文章平均质量分 67
xueda120
程序员
展开
-
(Problem 10)Summation of primes
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 2000000bool prim(int n){原创 2013-07-24 00:06:12 · 520 阅读 · 0 评论 -
(Problem 41)Pandigital prime
We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital and is also prime.What is the largest n-digit pandi原创 2013-07-26 20:03:24 · 499 阅读 · 0 评论 -
(Problem 37)Truncatable primes
The number 3797 has an interesting property. Being prime itself, it is possible to continuously remove digits from left to right, and remain prime at each stage: 3797, 797, 97, and 7. Similarly we c原创 2013-07-26 19:12:45 · 598 阅读 · 0 评论 -
(Problem 46)Goldbach's other conjecture
It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a prime and twice a square.9 = 7 + 21215 = 7 + 22221 = 3 + 23225 = 7 + 23227 = 19 + 222原创 2013-07-27 00:00:11 · 489 阅读 · 0 评论 -
(Problem 5)Smallest multiple
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.What is the smallest positive number that is evenly divisible by all of the numbers from 1原创 2013-07-26 11:26:03 · 478 阅读 · 0 评论 -
(Problem 6)Sum square difference
The sum of the squares of the first ten natural numbers is,12 + 22 + ... + 102 = 385The square of the sum of the first ten natural numbers is,(1 + 2 + ... + 10)2 = 552 = 3025Hence the diff原创 2013-07-26 11:02:05 · 658 阅读 · 0 评论 -
(Problem 2)Even Fibonacci numbers
Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...By considering t原创 2013-07-26 10:57:25 · 488 阅读 · 0 评论 -
(Problem 33)Digit canceling fractions
The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplify it may incorrectly believe that49/98 = 4/8, which is correct, is obtained by cancelling the 9s.原创 2013-07-26 00:49:20 · 592 阅读 · 0 评论 -
(Problem 34)Digit factorials
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原创 2013-07-25 23:13:57 · 623 阅读 · 0 评论 -
(Problem 35)Circular primes
The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime.There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71,原创 2013-07-26 13:19:25 · 653 阅读 · 0 评论 -
(Problem 7)10001st prime
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.What is the 10 001st prime number?#include #include #include #include int prim(int n){原创 2013-07-26 11:27:22 · 589 阅读 · 0 评论 -
(Problem 1)Multiples of 3 and 5
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.Find the sum of all the multiples of 3 or 5 below 1000.#include #i原创 2013-07-26 10:55:54 · 523 阅读 · 0 评论 -
(Problem 3)Largest prime factor
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 600851475143bool prim原创 2013-07-24 00:19:32 · 707 阅读 · 0 评论 -
(Problem 9)Special Pythagorean triplet
A Pythagorean triplet is a set of three natural numbers, a b c, for which,a2 + b2 = c2For example, 32 + 42 = 9 + 16 = 25 = 52.There exists exactly one Pythagorean triplet for which a + b +原创 2013-07-24 15:55:50 · 698 阅读 · 0 评论 -
(Problem 21)Amicable numbers
Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n).If d(a) = b and d(b) = a, where a b, then a and b are an amicable pair and each of a and b原创 2013-07-24 13:11:18 · 747 阅读 · 0 评论 -
(Problem 4)Largest palindrome product
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 99.Find the largest palindrome made from the product of two 3-digit nu原创 2013-07-24 11:38:10 · 498 阅读 · 0 评论 -
(Problem 14)Longest Collatz sequence
The following iterative sequence is defined for the set of positive integers:n n/2 (n is even)n 3n + 1 (n is odd)Using the rule above and starting with 13, we generate the following sequ原创 2013-07-28 13:19:46 · 766 阅读 · 0 评论