File tree 1 file changed +10
-5
lines changed
1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 1
1
"""
2
+ Lychrel numbers
3
+ Problem 55: https://projecteuler.net/problem=55
4
+
2
5
If we take 47, reverse and add, 47 + 74 = 121, which is palindromic.
6
+
3
7
Not all numbers produce palindromes so quickly. For example,
4
8
349 + 943 = 1292,
5
9
1292 + 2921 = 4213
6
10
4213 + 3124 = 7337
7
11
That is, 349 took three iterations to arrive at a palindrome.
12
+
8
13
Although no one has proved it yet, it is thought that some numbers, like 196,
9
14
never produce a palindrome. A number that never forms a palindrome through the
10
15
reverse and add process is called a Lychrel number. Due to the theoretical nature
@@ -48,14 +53,14 @@ def sum_reverse(n: int) -> int:
48
53
return int (n ) + int (str (n )[::- 1 ])
49
54
50
55
51
- def compute_lychrel_nums (limit : int ) -> int :
56
+ def solution (limit : int = 10000 ) -> int :
52
57
"""
53
58
Returns the count of all lychrel numbers below limit.
54
- >>> compute_lychrel_nums (10000)
59
+ >>> solution (10000)
55
60
249
56
- >>> compute_lychrel_nums (5000)
61
+ >>> solution (5000)
57
62
76
58
- >>> compute_lychrel_nums (1000)
63
+ >>> solution (1000)
59
64
13
60
65
"""
61
66
lychrel_nums = []
@@ -73,4 +78,4 @@ def compute_lychrel_nums(limit: int) -> int:
73
78
74
79
75
80
if __name__ == "__main__" :
76
- print (f"{ compute_lychrel_nums ( 10000 ) = } " )
81
+ print (f"{ solution ( ) = } " )
You can’t perform that action at this time.
0 commit comments