Return the least value of n for which least_divisible_repunit(n) first exceeds limit. >>> solution(10) 17 >>> solution(100) 109 >>> solution(1000) 1017
(limit: int = 1000000)
| 35 | |
| 36 | |
| 37 | def solution(limit: int = 1000000) -> int: |
| 38 | """ |
| 39 | Return the least value of n for which least_divisible_repunit(n) |
| 40 | first exceeds limit. |
| 41 | >>> solution(10) |
| 42 | 17 |
| 43 | >>> solution(100) |
| 44 | 109 |
| 45 | >>> solution(1000) |
| 46 | 1017 |
| 47 | """ |
| 48 | divisor = limit - 1 |
| 49 | if divisor % 2 == 0: |
| 50 | divisor += 1 |
| 51 | while least_divisible_repunit(divisor) <= limit: |
| 52 | divisor += 2 |
| 53 | return divisor |
| 54 | |
| 55 | |
| 56 | if __name__ == "__main__": |
no test coverage detected