Problem 63 Powerful digit counts

Problem 63: Powerful digit counts

https://projecteuler.net/problem=63

The 5-digit number, 16807=75, is also a fifth power. Similarly, the 9-digit number, 134217728=89, is a ninth power.

How many n-digit positive integers exist which are also an nth power?

分析

16807 是 5 位数,也是 7 的 5 次方
134217728 是 9[……]

>> 阅读全文…

Problem 62 Cubic permutations

Problem 62: Cubic permutations

https://projecteuler.net/problem=62

The cube, 41063625 (3453), can be permuted to produce two other cubes: 56623104 (3843) and 66430125 (4053). In fact, 41063625 is the smallest cube which has exactly three permutations of its digits which are also cube.

Find the sma[……]

>> 阅读全文…

Problem 61 Cyclical figurate numbers

Problem 61: Cyclical figurate numbers

https://projecteuler.net/problem=61

Triangle, square, pentagonal, hexagonal, heptagonal, and octagonal numbers are all figurate (polygonal) numbers and are generated by the following formulae:

Triangle P3,n=n(n+1)/2 1, 3, 6, 10, 15, …
Square[……]

>> 阅读全文…

Problem 60 Prime pair sets

Problem 60: Prime pair sets

https://projecteuler.net/problem=60

The primes 3, 7, 109, and 673, are quite remarkable. By taking any two primes and concatenating them in any order the result will always be prime. For example, taking 7 and 109, both 7109 and 1097 are prime. The sum of these four prim[……]

>> 阅读全文…

Problem 59 XOR decryption

Problem 59: XOR decryption

https://projecteuler.net/problem=59

Each character on a computer is assigned a unique code and the preferred standard is ASCII (American Standard Code for Information Interchange). For example, uppercase A = 65, asterisk (*) = 42, and lowercase k = 107.

A modern encrypti[……]

>> 阅读全文…

Problem 58 Spiral primes

Problem 58: Spiral primes

https://projecteuler.net/problem=58

Starting with 1 and spiralling anticlockwise in the following way, a square spiral with side length 7 is formed.

It is interesting to note that the odd squares lie along the bottom right diagonal, but what is more interesting is that 8[……]

>> 阅读全文…

Problem 57: Square root convergents

Problem 57: Square root convergents

https://projecteuler.net/problem=57

分析

每次扩展,相当于将 1/2 替换为 1/(2+1/2),所以

第 1 次扩展结果: fraction = 1 + 1/2
第 2 次扩展结果: fraction = 1 + 1/(2+1/2)
第 3 次扩展结果: fraction = 1 + 1/(2+1/(2+1/2))
第 4 次扩展结果: fraction = 1 + 1/(2+1/(2+1/(2+1/2)))
第 5 次扩展结果: fraction = 1 + 1/(2+1/(2[......]

>> 阅读全文...

Problem 56 Powerful digit sum

Problem 56: Powerful digit sum

https://projecteuler.net/problem=56

A 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 each number is only 1.

Considering natura[……]

>> 阅读全文…

Problem 55 Lychrel numbers

Problem 55: Lychrel numbers

https://projecteuler.net/problem=55

If we take 47, reverse and add, 47 + 74 = 121, which is palindromic.

Not all numbers produce palindromes so quickly. For example,

349 + 943 = 1292,
1292 + 2921 = 4213
4213 + 3124 = 7337

That is, 349 took three iterations to arrive at[……]

>> 阅读全文…

Problem 54 Poker hands

Problem 54: Poker hands

https://projecteuler.net/problem=54

download poker.txt

分析

扑克游戏

扑克游戏中,一手牌包括5张卡牌,并且等级(rank)从低到高排序如下:

  • 高牌,即大散牌(High Card): Highest value card.
  • 一对(One Pair)
  • 两对(Two Pairs)
  • 三条(Three of a Kind)
  • 顺子(Straight)
  • 同花(Flush)
  • 葫芦,即三条+一对(Full House)
  • 四条(Four of a Kind)
  • 同花顺(Straight Flush)
  • 皇家[……]

    >> 阅读全文…

Problem 53 Combinatoric selections

Problem 53: Combinatoric selections

https://projecteuler.net/problem=53

分析

组合 C(n,r) 表示从 n 个数中选择 r 个数选择方案的总数。 当 1 ≤ n ≤ 1000时, 统计有多少个 C(n,r) 的值超过了 1 百万。

思路很简单直接,难点是如果采用非python的实现,计算阶乘时存在大数问题。所以需要对 C(n,r) 的计算做优化,避免大数问题。

C(n,r) = n! / r!(n-r)!,计算过程中,可以先做约分,再计算最终结果。假设 max = max(r,n-r). 可以先约去 max!。 m[……]

>> 阅读全文…

Problem 52 Permuted multiples

Problem 52: Permuted multiples

https://projecteuler.net/problem=52

It 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 6x, contain the same digits.

分析

找到最小的整数[……]

>> 阅读全文…

Problem 51 Prime digit replacements

Problem 51: Prime digit replacements

https://projecteuler.net/problem=51

By 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 with the same digit, this 5-digit[……]

>> 阅读全文…

Problem 50 Consecutive prime sum

Problem 50: Consecutive prime sum

https://projecteuler.net/problem=50

The prime 41, can be written as the sum of six consecutive primes:

41 = 2 + 3 + 5 + 7 + 11 + 13
This is the longest sum of consecutive primes that adds to a prime below one-hundred.

The longest sum of consecutive primes below on[……]

>> 阅读全文…

Problem 44 Pentagon numbers

Problem 44: Pentagon numbers

https://projecteuler.net/problem=44

Pentagonal 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. However, their difference, 70 − 22 = 48[……]

>> 阅读全文…