OFFSET
1,1
COMMENTS
The smallest available 10-digit integer to start S with is a(1) = 1000000000.
The sequence is infinite as there are infinitely many integers whose 9 of the last 10 digits sum to a square.
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..10000
EXAMPLE
We start with a(1) = 1000000000:
S = 1000000000,
The last 10 digits of S are [1000000000]; we discard a 0 and the sum of the 9 remaining digits = 1 (a square). We try to extend S with 0:
S = 1000000000,0,
The last 10 digits of S are [0000000000]; we discard a 0 and the sum of the 9 remaining digits = 0 (a square). We try to extend S with 1:
S = 1000000000,0,1,
The last 10 digits of S are [0000000001]; we discard a 0 and the sum of the 9 remaining digits = 1 (a square). We try to extend S with 2:
S = 1000000000,0,1,2,
The last 10 digits of S are [0000000012]; we discard 2 and the sum of the 9 remaining digits = 1 (a square). We try to extend S with 3:
S = 1000000000,0,1,2,3,
The last 10 digits of S are [0000000123]; we discard 2 and the sum of the 9 remaining digits = 4 (a square). We try to extend S with 4:
S = 1000000000,0,1,2,3,4,
The last 10 digits of S are [0000001234]; we discard 1 and the sum of the 9 remaining digits = 9 (a square). We try to extend S with 5:
S = 1000000000,0,1,2,3,4,5,
The last 10 digits of S are [0000012345]; as no square can be reached, whatever we discard, we don’t extend S with 5. We try to extend S with 6:
S = 1000000000,0,1,2,3,4,6,
The last 10 digits of S are [0000012346]; we discard a 0 and the sum of the 9 remaining digits = 16 (a square).
Etc.
PROG
(Python)
from itertools import count, islice, combinations
def f(k, last10):
d = list(map(int, str(k)))
if len(d) >= 10: return d[-10:]
else: return last10[len(d):] + d
def c(k, last10):
for pick9 in combinations(f(k, last10), 9):
if sum(pick9) in {0, 1, 4, 9, 16, 25, 36, 49, 64, 81}:
return True
return False
def agen(): # generator of terms
an, seen, last10, mink = 1000000000, set(), [], 0
while True:
yield an
seen.add(an)
last10 = f(an, last10)
an = next(k for k in count(mink) if k not in seen and c(k, last10))
while mink in seen: mink += 1
print(list(islice(agen(), 66))) # Michael S. Branicky, Aug 14 2024
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Eric Angelini, Aug 14 2024
EXTENSIONS
a(14) and beyond from Michael S. Branicky, Aug 14 2024
STATUS
approved