Project Euler
文章平均质量分 73
wxinbeings
前几天发现了 projecteluer.net 网站,感觉里面的题目很有意思,打算每天更新一篇博客,内容主要是 Project Euler Problem 的个人解答。其中解答内容仅代表个人观点,如有错误,可以一起讨论,一起学习,谢谢。
展开
-
Project Euler Problem 57
Problem 57It is possible to show that the square root of two can be expressed as an infinite continued fraction.√ 2 = 1 + 1/(2 + 1/(2 + 1/(2 + … ))) = 1.414213…By expanding this for the first four ite...原创 2018-07-16 09:58:58 · 229 阅读 · 0 评论 -
Project Euler Problem 43
Problem 43The number, 1406357289, is a 0 to 9 pandigital number because it is made up of each of the digits 0 to 9 in some order, but it also has a rather interesting sub-string divisibility property....原创 2018-06-21 23:10:50 · 164 阅读 · 0 评论 -
Project Euler Problem40
Problem 40An irrational decimal fraction is created by concatenating the positive integers:0.123456789101112131415161718192021...It can be seen that the 12th digit of the fractional part is 1.If dn re...原创 2018-06-13 21:47:09 · 134 阅读 · 0 评论 -
Project Problem 37
Problem 37The 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. Simila...原创 2018-05-28 22:35:33 · 101 阅读 · 0 评论 -
Project Euler Problem 33
Problem 32Digit cancelling fractionsThe fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplify it may incorrectly believe that 49/98 = 4/8, which is correct,...原创 2018-05-16 22:19:07 · 195 阅读 · 0 评论 -
Project Euler Problem 38
Problem 38Take the number 192 and multiply it by each of 1, 2, and 3:192 × 1 = 192192 × 2 = 384192 × 3 = 576By concatenating each product we get the 1 to 9 pandigital, 192384576. We will call 19238457...原创 2018-06-02 20:35:29 · 157 阅读 · 0 评论 -
Project Euler Problem 32
Problem 32We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once; for example, the 5-digit number, 15234, is 1 through 5 pandigital.The product 7254 is...原创 2018-05-15 21:21:45 · 194 阅读 · 0 评论 -
Project Euler Problem 36
Problem 36The 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...原创 2018-05-25 20:53:53 · 122 阅读 · 0 评论 -
Project Euler Problem 35
Project 35The 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,...原创 2018-05-21 22:03:07 · 138 阅读 · 0 评论 -
Project Euler Problem 26
Problem 26A unit fraction contains 1 in the numerator. The decimal representation of the unit fractions with denominators 2 to 10 are given:1/2= 0.51/3= 0.(3)1/4= 0.251/5= 0.21/6= 0.1(6)1/7= 0.(142857...原创 2018-05-07 21:52:33 · 292 阅读 · 0 评论 -
Project Euler Problem 19
Problem 19You are given the following information, but you may prefer to do some research for yourself.1 Jan 1900 was a Monday.Thirty days has September,April, June and November.All the rest have thir...原创 2018-04-29 23:01:34 · 153 阅读 · 0 评论 -
Project Euler Problem 18
Problem 18By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23.37 42 4 68 5 9 3That is, 3 + 7 + 4 + 9 = 23.Find the ...原创 2018-04-28 21:06:13 · 200 阅读 · 1 评论 -
Project Euler Problem 39
Problem 39If p is the perimeter of a right angle triangle with integral length sides, {a,b,c}, there are exactly three solutions for p = 120.{20,48,52}, {24,45,51}, {30,40,50}For which value of p ≤ 10...原创 2018-06-08 20:12:56 · 196 阅读 · 0 评论 -
Project Euler Problem 41
Problem 41We 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-dig...原创 2018-06-17 18:57:55 · 328 阅读 · 0 评论 -
Project Euler Problem 42
Problem 42The nth term of the sequence of triangle numbers is given by, tn = 1/2n(n+1); so the first ten triangle numbers are:1, 3, 6, 10, 15, 21, 28, 36, 45, 55, …By converting each letter in a word ...原创 2018-06-18 19:35:01 · 250 阅读 · 0 评论 -
Project Euler Problem 56
Problem 56A googol (10100) is a massive number: one followed by one-hundred zeros; 100100 is almost unimaginably large: one followed by two-hundred zeros. Despite their size, the sum of the digits in ...原创 2018-07-16 09:55:16 · 190 阅读 · 0 评论 -
Project Euler Problem 55
Problem 55If we take 47, reverse and add, 47 + 74 = 121, which is palindromic.Not all numbers produce palindromes so quickly. For example,349 + 943 = 12921292 + 2921 = 42134213 + 3124 = 7337That is, 3...原创 2018-07-16 09:51:14 · 229 阅读 · 0 评论 -
Project Euler Problem 53
Problem 53There are exactly ten ways of selecting three from five, 12345:123, 124, 125, 134, 135, 145, 234, 235, 245, and 345In combinatorics, we use the notation, 5C3 = 10.In general,nCr=n!r!(n−r)!, ...原创 2018-07-16 09:48:15 · 238 阅读 · 0 评论 -
Project Euler Problem 52
Problem 52It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order.Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and...原创 2018-07-16 09:46:03 · 184 阅读 · 0 评论 -
Project Euler Problem 51
Problem 51By replacing the 1st digit of the 2-digit number *3, it turns out that six of the nine possible values: 13, 23, 43, 53, 73, and 83, are all prime.By replacing the 3rd and 4th digits of 56**3...原创 2018-07-16 09:42:14 · 225 阅读 · 0 评论 -
Project Euler Problem 50
Problem 50The prime 41, can be written as the sum of six consecutive primes:41 = 2 + 3 + 5 + 7 + 11 + 13This is the longest sum of consecutive primes that adds to a prime below one-hundred.The longest...原创 2018-07-16 09:37:53 · 123 阅读 · 0 评论 -
Project Euler Problem 49
Problem 49The arithmetic sequence, 1487, 4817, 8147, in which each of the terms increases by 3330, is unusual in two ways: (i) each of the three terms are prime, and, (ii) each of the 4-digit numbers ...原创 2018-07-16 09:35:00 · 176 阅读 · 0 评论 -
Project Euler Problem 48
Problem 48The series, 11 + 22 + 33 + … + 1010 = 10405071317.Find the last ten digits of the series, 11 + 22 + 33 + … + 10001000.十项的自幂级数求和为 11 + 22 + 33 + … + 1010 = 10405071317。求如下一千项的自幂级数求和的最后10位数字:1...原创 2018-06-27 23:37:48 · 322 阅读 · 0 评论 -
Project Euler Problem 47
Problem 47The first two consecutive numbers to have two distinct prime factors are:14 = 2 × 715 = 3 × 5The first three consecutive numbers to have three distinct prime factors are:644 = 22 × 7 × 23645...原创 2018-06-27 23:17:56 · 147 阅读 · 0 评论 -
Project Euler Problem 46
Problem 46It 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 + 2×1215 = 7 + 2×2221 = 3 + 2×3225 = 7 + 2×3227 = 19 + 2×2...原创 2018-06-27 23:15:28 · 150 阅读 · 0 评论 -
Project Euler Problem 45
Problem 45Triangle, pentagonal, and hexagonal numbers are generated by the following formulae: TriangleTn=n(n+1)/21, 3, 6, 10, 15, …PentagonalPn=n(3n−1)/21, 5, 12, 22, 35, …HexagonalHn=n(2n−1)1, 6, ...原创 2018-06-27 23:14:11 · 194 阅读 · 0 评论 -
Project Euler Problem 44
Problem 44Pentagonal numbers are generated by the formula, Pn=n(3n−1)/2. The first ten pentagonal numbers are:1, 5, 12, 22, 35, 51, 70, 92, 117, 145, …It can be seen that P4 + P7 = 22 + 70 = 92 = P8. ...原创 2018-06-27 23:11:54 · 154 阅读 · 0 评论 -
Project Euler Problem 34
problem 34145 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 ...原创 2018-05-19 19:49:03 · 182 阅读 · 0 评论 -
Project Euler Problem 27
Problem 27Euler discovered the remarkable quadratic formula:n2 + n + 41It turns out that the formula will produce 40 primes for the consecutive values n = 0 to 39. However, when n = 40, 402 + 40 + 41 ...原创 2018-05-06 21:40:30 · 270 阅读 · 0 评论 -
Project Euler Problem 17
Problem 17If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.If all the numbers from 1 to 1000 (one thousand) incl...原创 2018-04-27 22:22:16 · 168 阅读 · 0 评论 -
Project Euler Problem 20
Problem 20n! means n × (n − 1) × ... × 3 × 2 × 1For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800,and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.Find the sum of the ...原创 2018-05-01 21:04:16 · 102 阅读 · 0 评论 -
Project Euler Problem 9
Problem 9A 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...原创 2018-04-19 22:31:34 · 158 阅读 · 0 评论 -
Project Euler Problem 13
Problem 13Work out the first ten digits of the sum of the following one-hundred 50-digit numbers.# 计算100个50位数的和,求前十位。f = open('problem13data.txt','r')data_list1 = f.readlines()data_list2 = [x.strip(...原创 2018-04-23 21:38:15 · 121 阅读 · 0 评论 -
Project Euler Problem 3
Problem 3The prime factors of 13195 are 5, 7, 13 and 29.What is the largest prime factor of the number 600851475143 ?# 求解600851475143的最大质因数。# 其中分解质因数是难点def isprime(n): # 定义一个判断是否是质数的函数 ...原创 2018-04-13 21:06:02 · 211 阅读 · 0 评论 -
Project Euler Problem 8
Problem 8The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832.7316717653133062491922511967442657474235534919493496983520312774506326239578318016984...原创 2018-04-18 22:35:34 · 209 阅读 · 0 评论 -
Project Euler Problem 12
Problem 12The 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,...原创 2018-04-22 21:05:34 · 147 阅读 · 0 评论 -
Project Euler Problem 2
Problem 2Each 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...原创 2018-04-12 23:05:26 · 144 阅读 · 0 评论 -
Project Euler Problem 1
前几天发现了 projecteluer.net 网站,感觉里面的题目很有意思,便打算每天更新一篇博客,内容主要是 Project Euler Problem 的个人解答。其中解答内容仅代表个人观点,如果有错误或者异议,可以一起讨论,一起学习,谢谢。Problem 1If we list all the natural numbers below 10 that are multip...原创 2018-04-12 22:38:03 · 251 阅读 · 0 评论 -
Project Euler Problem 7
Problem 7By 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?# 求第10001个素数。count = 0i = 2while True: for j in ran...原创 2018-04-17 22:25:54 · 106 阅读 · 0 评论 -
Project Euler Problem 6
Problem 6The 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 differenc...原创 2018-04-16 20:55:55 · 103 阅读 · 0 评论