File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 11"""
2+ Lychrel numbers
3+ Problem 55: https://projecteuler.net/problem=55
4+
25If we take 47, reverse and add, 47 + 74 = 121, which is palindromic.
6+
37Not all numbers produce palindromes so quickly. For example,
48349 + 943 = 1292,
591292 + 2921 = 4213
6104213 + 3124 = 7337
711That is, 349 took three iterations to arrive at a palindrome.
12+
813Although no one has proved it yet, it is thought that some numbers, like 196,
914never produce a palindrome. A number that never forms a palindrome through the
1015reverse and add process is called a Lychrel number. Due to the theoretical nature
@@ -48,14 +53,14 @@ def sum_reverse(n: int) -> int:
4853 return int (n ) + int (str (n )[::- 1 ])
4954
5055
51- def compute_lychrel_nums (limit : int ) -> int :
56+ def solution (limit : int = 10000 ) -> int :
5257 """
5358 Returns the count of all lychrel numbers below limit.
54- >>> compute_lychrel_nums (10000)
59+ >>> solution (10000)
5560 249
56- >>> compute_lychrel_nums (5000)
61+ >>> solution (5000)
5762 76
58- >>> compute_lychrel_nums (1000)
63+ >>> solution (1000)
5964 13
6065 """
6166 lychrel_nums = []
@@ -73,4 +78,4 @@ def compute_lychrel_nums(limit: int) -> int:
7378
7479
7580if __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