Last old solutions with code good enough to publish.

master
Tibor Bizjak 2023-03-28 01:58:58 +02:00
parent 073423a316
commit de6b3e89bd
2 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,29 @@
#!/usr/bin/env python3
def nofdivs(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] += sieve[i] // pw
pw += 1
return sieve
bound = 10**5
sieve = nofdivs(bound)
target = 500
for n in range(1, bound-1):
if n % 2:
a, b = (n + 1)//2, n
else:
a, b = n//2, n+1
if sieve[a] * sieve[b] > target:
print(a * b)
break

View File

@ -0,0 +1,3 @@
#!/usr/bin/env python3
print(sum(pow(x, x, (10**10)) for x in range(1,1000+1)) % 10**10)