project-euler/174_square_laminae.py

19 lines
405 B
Python

#!/usr/bin/env python3
def divisors(n):
sieve = [1]*n
for p in range(2, n):
if sieve[p] > 1:
continue
pw = 1
while p**pw < n:
for i in range(p**pw, n, p**pw):
sieve[i] *= (pw+1)
sieve[i] //= pw
pw += 1
return sieve
n = 10**6 // 4
divs = divisors(n+1)
print(len([0 for i in divs if 0 < i//2 <= 10]))