
Python
一起来玩玩呗
just to fun...
展开
-
projecteuler---->problem=16----Power digit sum
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?翻译:215 = 32768的各位数之和为3 + 2 + 7 + 6 + 8 = 26。那么21000的各位数之和为……?import原创 2014-06-03 15:47:31 · 1165 阅读 · 0 评论 -
projecteuler---->problem=10----Summation of primes
title:The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.Find the sum of all the primes below two million.翻译:10以下的质数的和为2 + 3 + 5 + 7 = 17。请求出200,0000以下所有质数的和。import math,timed原创 2014-05-31 10:38:00 · 964 阅读 · 0 评论 -
projecteuler---->problem=11----Largest product in a grid
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 0849 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56原创 2014-05-31 11:50:29 · 1092 阅读 · 0 评论 -
projecteuler---->problem=13----Large sum
title:Work out the first ten digits of the sum of the following one-hundred 50-digit numbers.371072875339021027987979982208375902465101357402504637693767749000971264812489697007805041701826053原创 2014-05-31 15:51:43 · 1032 阅读 · 0 评论 -
projecteuler---->problem=14----Longest Collatz sequence
title: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 followi原创 2014-06-03 10:16:43 · 1315 阅读 · 0 评论 -
projecteuler---->problem=15----Lattice paths
Starting in the top left corner of a 22 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner.How many such routes are there through a 20原创 2014-06-03 16:43:24 · 1252 阅读 · 1 评论 -
Project Euler 26 计算小数位循环的位数
A 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原创 2014-08-20 15:34:30 · 1610 阅读 · 0 评论 -
Python集合(set)类型的操作
python的set和其他语言类似, 是一个无序不重复元素集, 基本功能包括关系测试和消除重复元素. 集合对象还支持union(联合), intersection(交), difference(差)和sysmmetric difference(对称差集)等数学运算.sets 支持 x in set, len(set),和 for x in set。作为一个无序的集合,sets不记录元素位置或者转载 2014-08-21 08:07:28 · 615 阅读 · 0 评论 -
projecteuler---->problem=29----Distinct powers
Problem 29Consider all integer combinations of ab for 2 ≤ a ≤ 5 and 2 ≤ b ≤ 5:22=4, 23=8, 24=16, 25=3232=9, 33=27, 34=81, 35=24342=16, 43=64, 44=256, 45=102452=25, 53=125, 54=625, 55=312原创 2014-08-21 08:21:10 · 1152 阅读 · 0 评论 -
projecteuler---->problem=28----Number spiral diagonals
Problem 28Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows:21 22 23 24 2520 7 8 9 1019 6 1 2 1118 5 4 3 1217 16原创 2014-08-20 17:00:28 · 1023 阅读 · 0 评论 -
projecteuler---->problem=27----Quadratic primes
Euler discovered the remarkable quadratic formula:n² + 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 = 40原创 2014-08-20 16:06:43 · 1143 阅读 · 0 评论 -
projecteuler---->problem=30----Digit fifth powers
Problem 30Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits:1634 = 14 + 64 + 34 + 448208 = 84 + 24 + 04 + 849474 = 94 + 44 + 74 + 44原创 2014-08-21 09:36:07 · 1194 阅读 · 0 评论 -
projecteuler---->problem=31----Coin sums 无限背包计算可能存在的次数
Problem 31In England the currency is made up of pound, £, and pence, p, and there are eight coins in general circulation:1p, 2p, 5p, 10p, 20p, 50p, £1 (100p) and £2 (200p).It is possible to原创 2014-08-21 11:09:46 · 1475 阅读 · 0 评论 -
projecteuler---->problem=32----Pandigital products
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 produ原创 2014-08-22 15:28:57 · 1473 阅读 · 0 评论 -
projecteuler---->problem=33----Digit canceling fractions
Problem 33The 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 cance原创 2014-08-22 16:07:49 · 1270 阅读 · 0 评论 -
projecteuler---->problem=9----Special Pythagorean triplet
title: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 wh原创 2014-05-31 09:36:45 · 1167 阅读 · 0 评论 -
projecteuler---->problem=12----Highly divisible triangular number
title: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,原创 2014-05-31 13:40:50 · 1145 阅读 · 0 评论 -
projecteuler---->problem=8----Largest product in a series
title:The four adjacent digits in the 1000-digit number that have the greatest product are 9 9 8 9 = 5832.731671765313306249192251196744265747423553491949349698352031277450632623957831原创 2014-05-31 09:34:36 · 1715 阅读 · 0 评论 -
projecteuler---->problem=19----Counting Sundays
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原创 2014-06-05 07:55:42 · 1146 阅读 · 0 评论 -
projecteuler---->problem=21----Amicable numbers
Let d(n) be defined as the sum of proper divisors of n (numbers less thann 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 andb原创 2014-06-05 08:50:31 · 1153 阅读 · 0 评论 -
projecteuler---->problem=22----Names scores
sing 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 v原创 2014-06-05 10:19:32 · 1333 阅读 · 0 评论 -
projecteuler---->problem=20----Factorial digit sum
n! 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 digits原创 2014-06-05 08:26:43 · 1331 阅读 · 0 评论 -
projecteuler---->problem=23----Non-abundant sums
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原创 2014-06-07 11:19:34 · 1255 阅读 · 0 评论 -
projecteuler---->problem=24----Lexicographic permutations
问题描述:A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabeti原创 2014-06-09 16:50:01 · 1183 阅读 · 0 评论 -
projecteuler---->problem=25----1000-digit Fibonacci number
问题描述:The Fibonacci sequence is defined by the recurrence relation:Fn = Fn1 + Fn2, where F1 = 1 and F2 = 1.Hence the first 12 terms will be:F1 = 1F2 = 1F3 = 2F4 = 3F5 = 5F6 = 8原创 2014-06-09 17:07:54 · 1160 阅读 · 0 评论 -
projecteuler---->problem=7----10001st prime
title: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?翻译:通过列出前6个质数,我们可知第6个质数是13。那么第10001个质数是原创 2014-05-28 20:43:56 · 914 阅读 · 0 评论 -
projecteuler---->problem=6----Sum square difference
title: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原创 2014-05-28 16:53:57 · 970 阅读 · 0 评论 -
projecteuler---->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 ?翻译:13195的质因数有5丶7丶13丶29。问:600851475143的最大质因数是……?解答:import matha=6原创 2014-05-28 11:50:58 · 938 阅读 · 0 评论 -
projecteuler---->problem=4----Largest palindrome product
title:Largest palindrome productProblem 4A 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 l原创 2014-05-28 15:36:17 · 1033 阅读 · 0 评论 -
projecteuler---->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 consider原创 2014-05-28 11:46:42 · 879 阅读 · 0 评论 -
projecteuler---->problem=5----Smallest multiple n个数求最小公倍数
title: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 nu原创 2014-05-28 16:50:03 · 1386 阅读 · 0 评论 -
projecteuler---->problem=35----Circular primes
Problem 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,原创 2014-08-22 17:05:15 · 1420 阅读 · 0 评论