-
Notifications
You must be signed in to change notification settings - Fork 0
/
A243843.py
47 lines (42 loc) · 1.06 KB
/
A243843.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#! /usr/bin/env python3
# A243843: a(n) is the smallest squarefree semiprime that belongs to a sequence of length n under repeated iteration of the map
# (k -> concatenation of prime divisors of k in increasing order) until a number is reached that is not a squarefree semiprime.
from labmath import *
results = {}
minunknown = 1
for x in semiprimegen():
if isqrt(x)**2 == x: continue
if x % 1000 == 1: print('\b'*42, minunknown, x, len(results), end="...", flush=True)
y = x
iters = 0
while True:
p = next(primefac(x))
q = x // p
if q == 1 or p == q or not isprime(q): break
x = int(str(min(p,q)) + str(max(p,q)))
iters += 1
if iters in results: continue
results[iters] = y
if iters != minunknown: continue
while minunknown in results:
print('\b'*42, minunknown, results[minunknown], len(results), end=" \n")
minunknown += 1
"""
1 6
2 38
3 34
4 15
5 265
6 161
7 1126
8 4891
9 1253
10 250231
11 100462
12 49869178
13 234139657
14 68279314
15 2318271253
16 636542506
17 > 10**10
"""