随笔分类 -  欧拉计划(C语言)

摘要:The decimal number, 585 = 10010010012(binary), is palindromic in both bases.Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2.(Please note that the palindromic number, in either base, may not include leading zeros.) 1 #include 2 #include 3 #include 4 5 . 阅读全文
posted @ 2013-10-31 21:39 cpoint
摘要:The following iterative sequence is defined for the set of positive integers: nn/2 (nis even)n3n+ 1 (nis odd)Using the rule above and starting with 13, we generate the following sequence:134020105168421It can be seen that this sequence (starting at 13 and finishing at 1) contains 10 terms. Although 阅读全文
posted @ 2013-07-28 13:19 cpoint
摘要: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 + 22233 = 31 + 212It turns out that the conjecture was false.What is the smallest odd composite that cannot be written 阅读全文
posted @ 2013-07-27 00:00 cpoint
摘要:We shall say that ann-digit number is pandigital if it makes use of all the digits 1 tonexactly once. For example, 2143 is a 4-digit pandigital and is also prime.What is the largestn-digit pandigital prime that exists? 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 8 bool ispri. 阅读全文
posted @ 2013-07-26 20:03 cpoint
摘要: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 can work from right to left: 3797, 379, 37, and 3.Find the sum of the only eleven primes that are both 阅读全文
posted @ 2013-07-26 19:12 cpoint
摘要: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, 73, 79, and 97.How many circular primes are there below one million?#include #include #include #inclu 阅读全文
posted @ 2013-07-26 13:19 cpoint
摘要: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? 1 #include 2 #include 3 #include 4 #include 5 6 int prim(int n) 7 { 8 int i; 9 for(i=2; i*i<=n; i++)10 {11 if(n%i==0)12 return 0;13 ... 阅读全文
posted @ 2013-07-26 11:27 cpoint
摘要: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 isevenly divisibleby all of the numbers from 1 to 20? 1 #include 2 #include 3 #include 4 #include 5 6 #define N 20 7 8 int gcd(int a, int b) 9... 阅读全文
posted @ 2013-07-26 11:26 cpoint
摘要: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 difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025385 = 2640.Fi 阅读全文
posted @ 2013-07-26 11:02 cpoint
摘要: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 the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-value 阅读全文
posted @ 2013-07-26 10:57 cpoint
摘要: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. 1 #include 2 #include 3 #include 4 5 void solve() 6 { 7 int sum,i; 8 sum=0; 9 for(i=3; i<1000; i++)10 ... 阅读全文
posted @ 2013-07-26 10:55 cpoint
摘要:The fraction49/98is 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.We shall consider fractions like,30/50=3/5, to be trivial examples.There are exactly four non-trivial examp 阅读全文
posted @ 2013-07-26 00:49 cpoint
摘要: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.#include #include #include #include #include #include int factorial(int n) //阶乘函数 { ... 阅读全文
posted @ 2013-07-25 23:13 cpoint
摘要:Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows:2122 23 242520 78 91019 6 12 1118 54 3121716 15 1413It can be verified that the sum of the numbers on the diagonals is 101.What is the sum of the numbers on the diagonals in a 1001 by 100 阅读全文
posted @ 2013-07-25 21:34 cpoint
摘要: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++... 阅读全文
posted @ 2013-07-24 15:55 cpoint
摘要: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 阅读全文
posted @ 2013-07-24 13:11 cpoint

浏览次数:travelocity promotion codes