EKG sequence convergence: Difference between revisions

Content added Content deleted
(→‎{{header|Python}}: Add method using math.gcd)
(→‎Python: Using prime factor generation: Use next() instead of __next__())
Line 226: Line 226:
while True:
while True:
while not min_share_pf_so_far(last_pf, so_far):
while not min_share_pf_so_far(last_pf, so_far):
so_far.append(pf_gen.__next__())
so_far.append(next(pf_gen))
yield found[0], [n for n, _ in so_far]
yield found[0], [n for n, _ in so_far]
last, last_pf = found
last, last_pf = found
Line 234: Line 234:
ekg = [EKG_gen(n) for n in ekgs]
ekg = [EKG_gen(n) for n in ekgs]
for e in ekg:
for e in ekg:
e.__next__() # skip initial 1 in each sequence
next(e) # skip initial 1 in each sequence
differ = list(takewhile(lambda state: not all(state[0] == s for s in state[1:]),
differ = list(takewhile(lambda state: not all(state[0] == s for s in state[1:]),
islice(zip(*ekg), limit-1)))
islice(zip(*ekg), limit-1)))