project-euler/346_strong_repunits.py

17 lines
271 B
Python

#!/usr/bin/env python3
bound = 10**12
nums = set()
nums.add(1)
for base in range(2, int(bound**0.5)+1):
r = base**2 + base + 1
pw = 3
while r < bound:
if r not in nums:
nums.add(r)
r += base**pw
pw += 1
print(sum(nums))