Skip to content

Instantly share code, notes, and snippets.

@firegurafiku
Created April 6, 2024 22:48
Show Gist options
  • Save firegurafiku/496a2ee5aa1c01024b33c3419e4ed6fd to your computer and use it in GitHub Desktop.
Save firegurafiku/496a2ee5aa1c01024b33c3419e4ed6fd to your computer and use it in GitHub Desktop.
from math import *
import itertools
def count(seq):
c = 0
for _ in seq:
c += 1
return c
def exactlyOne(seq):
alreadyMet = False
for val in seq:
if val:
if alreadyMet:
return False
else:
alreadyMet = True
return alreadyMet
def Ks(S):
for a in itertools.count(2):
b = S - a
if a > b:
break
yield (a, b)
def Kp(P):
for p in itertools.count(2):
if P % p != 0:
continue
q = P // p
if p >= 100 or p > q:
break
if q >= 100:
continue
yield (p, q)
def pred0S(S):
return count(Ks(S)) > 1
def pred0(P):
return count(Kp(P)) > 1
def pred1(S):
return pred0S(S) and all(pred0(a * b) for (a, b) in Ks(S))
def pred2(P):
return pred0(P) and \
exactlyOne(pred1(p + q) for p, q in Kp(P))
def pred3(S):
return pred1(S) and \
exactlyOne(pred2(a * b) for a, b in Ks(S))
for S in range(4, 99+99+1):
if pred3(S):
print(S)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment