MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / solution

Function solution

project_euler/problem_055/sol1.py:56–77  ·  view source on GitHub ↗

Returns the count of all lychrel numbers below limit. >>> solution(10000) 249 >>> solution(5000) 76 >>> solution(1000) 13

(limit: int = 10000)

Source from the content-addressed store, hash-verified

54
55
56def solution(limit: int = 10000) -> int:
57 """
58 Returns the count of all lychrel numbers below limit.
59 >>> solution(10000)
60 249
61 >>> solution(5000)
62 76
63 >>> solution(1000)
64 13
65 """
66 lychrel_nums = []
67 for num in range(1, limit):
68 iterations = 0
69 a = num
70 while iterations < 50:
71 num = sum_reverse(num)
72 iterations += 1
73 if is_palindrome(num):
74 break
75 else:
76 lychrel_nums.append(a)
77 return len(lychrel_nums)
78
79
80if __name__ == "__main__":

Callers 1

sol1.pyFile · 0.70

Calls 3

sum_reverseFunction · 0.85
is_palindromeFunction · 0.70
appendMethod · 0.45

Tested by

no test coverage detected