Project Euler
文章平均质量分 58
liaoxingyi
这个作者很懒,什么都没留下…
展开
-
Project Euler - Problem 2
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原创 2012-05-05 07:46:25 · 256 阅读 · 0 评论 -
Project Eurler - Problem 1
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. 通常解法: def Su原创 2012-05-05 07:42:25 · 289 阅读 · 0 评论 -
Project Euler - Problem 4
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 X 99. Find the largest palindrome made from the product of two 3-digit原创 2012-05-05 07:52:00 · 248 阅读 · 0 评论 -
Project Euler - Problem 9
A Pythagorean triplet is a set of three natural numbers, a b c, for which, a^2 + b^2 = c^2. For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2. There exists exactly one Pythagorean triplet for which a + b原创 2012-05-05 08:07:48 · 287 阅读 · 0 评论 -
Project Euler – Problem 10
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. 计算2000000一下的素数和,参照problem 7判断素数的办法。 static long sumOfPrimes(int n) { long sum = 17; fo原创 2012-05-05 08:11:02 · 301 阅读 · 0 评论 -
Project Euler – Problem 21
For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110; therefore d(220) = 284. The proper divisors of 284 are 1, 2, 4, 71 and 142; so d(284) = 220. Evaluate the sum o原创 2012-05-05 08:32:27 · 423 阅读 · 0 评论 -
Project Euler - Problem 8
Find the greatest product of five consecutive digits in the 1000-digit number. 73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 85861560789112原创 2012-05-05 08:05:50 · 276 阅读 · 0 评论 -
Project Euler – Problem 12
The 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, 21, 28,原创 2012-05-05 08:17:49 · 323 阅读 · 0 评论 -
Project Euler - Problem 13
Work out the first ten digits of the sum of the following one-hundred 50-digit numbers. 37107287533902102798797998220837590246510135740250 46376937677490009712648124896970078050417018260538 7432498原创 2012-05-05 08:19:35 · 317 阅读 · 0 评论 -
Project Euler - Problem 15
Starting in the top left corner of a 22 grid, there are 6 routes (without backtracking) to the bottom right corner. How many routes are there through a 2020 grid? 解法一: 当前点到目标点的路径数=右边点到目标点的路径数 +原创 2012-05-05 08:22:40 · 295 阅读 · 0 评论 -
Project Euler – Problem 23
A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means th原创 2012-05-05 08:37:49 · 448 阅读 · 0 评论 -
Project Euler – Problem 20
n! means n (n 1) … 3 2 1 For 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 digits in the number 100! #!/u原创 2012-05-05 08:30:42 · 265 阅读 · 0 评论 -
Project Euler – Problem 19
You 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 thirty-原创 2012-05-05 08:29:06 · 984 阅读 · 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、偶数的唯一素因子为2 2、任何数可以分解为有限个素数的乘积 可以参见因子分解算法,不断模不断求因子。 def LargestPrimeFactor(numbe原创 2012-05-05 07:48:34 · 337 阅读 · 0 评论 -
Project Eurler - Problem 7
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 10001st prime number? 这里采用简单的办法求素数,不过还是要讲究一点效率: 1、2是唯一的偶数素数 2、所有比3大的素数可以表示为6k+1或者6k-原创 2012-05-05 08:03:43 · 220 阅读 · 0 评论 -
Project Eluer - Problem 11
In the 2020 grid below, four numbers along a diagonal line have been marked in red. 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 5原创 2012-05-05 08:14:13 · 343 阅读 · 0 评论 -
Project Euler – Problem 14
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 sequence: 1原创 2012-05-05 08:20:58 · 310 阅读 · 0 评论 -
Project Euler – Problem 16
215 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number 21000? 用python绕开那些复杂的大数计算和溢出的考虑! #!/usr/bin/env python # coding: utf-8 def SumOfDigits(n原创 2012-05-05 08:23:45 · 268 阅读 · 0 评论 -
Project Euler – Problem 17
If 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) inclusive we原创 2012-05-05 08:26:02 · 418 阅读 · 0 评论 -
Project Euler – Problem 22
Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical va原创 2012-05-05 08:36:02 · 315 阅读 · 0 评论 -
Project Euler - Problem 5
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 to原创 2012-05-05 07:55:40 · 371 阅读 · 0 评论 -
Project Euler – Problem 18
By 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. 3 7 4 2 4 6 8 5 9 3 That is, 3 + 7 + 4 + 9 = 23. Find原创 2012-05-05 08:27:53 · 310 阅读 · 0 评论 -
Project Euler - Problem 6
The sum of the squares of the first ten natural numbers is, 12 + 22 + … + 102 = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + … + 10)2 = 552 = 3025 Hence the difference bet原创 2012-05-05 07:59:40 · 199 阅读 · 0 评论