OFFSET
0,2
PROG
(Python)
import numpy
input_list = []
output_list = []
max_list = []
range_ = 10 ** 7
lower = 0
upper = lower + range_
for i in range(lower, upper):
input_list.append(i)
number = str(i)
results_list = []
total = 0
total_list = []
while True:
number_list = []
for x in list(number):
number_list.append(int(x))
results_list.append(numpy.prod(number_list))
total += numpy.prod(number_list)
if total in total_list:
output_list.append(total_list[-1])
if total_list[-1] >= max(output_list):
if total_list[-1] not in max_list:
max_list.append(total_list[-1])
break
total_list.append(total)
number = str(total)
print(max_list)
(Python)
from math import prod
from itertools import count, islice
def pd(n): return prod(map(int, str(n)))
def f(x): return x + pd(x)
def agen(): # generator of terms
record, seen = -1, set()
for n in count(0):
x = pd(n)
if x in seen: continue
seen.add(x)
fx = f(x)
while x != fx: x, fx = fx, f(fx)
if fx > record:
record = fx
yield record
print(list(islice(agen(), 39))) # Michael S. Branicky, Jun 21 2022
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Marc-Thomas Russo, Jun 03 2022
STATUS
approved