VOOZH about

URL: https://oeis.org/A359143/a359143.py.txt


# Python program for an iteration defined by Eric Angelini [now OEIS A359143] # by Michael S. Branicky [written Jul 26 2022] # [to convert strings to numbers in A359143, use: an = int(s) if s[0] != "0" else -int(s)] # SOURCE: # Eric Angelini, Add and erase: does the iteration end?, math-fun mailing list, Jul 26 2022 def iterate(s, printevery=10**6): i, seen, longest = 0, {s}, s while True: i += 1 addon = str(sum(map(int, s))) s += addon if s[0] in addon: s = s.replace(s[0], "") if len(s) > len(longest): longest = s if len(s) == 0: print(f"empty string ('{s}') reached at step {i}") print(f"longest string encountered: {longest} (length {len(longest)})") break if s in seen: print(f"cycle reached at step {i}, string '{s}'") print(f"longest string encountered: {longest} (length {len(longest)})") break seen.add(s) if i%printevery == 0: print(f"iteration {i}: {s} (length {len(s)})") iterate("11", printevery=10**5)