Returns the count of all lychrel numbers below limit. >>> solution(10000) 249 >>> solution(5000) 76 >>> solution(1000) 13
(limit: int = 10000)
| 54 | |
| 55 | |
| 56 | def 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 | |
| 80 | if __name__ == "__main__": |
no test coverage detected