login
A074807
Number of steps needed to reach a prime when the following map is repeatedly applied to n: if n is even then 2n + POD(n) + 1, otherwise 2n - POD(n) - 1, where POD(n) is the product of the digits of n; or -1 if no prime is ever reached.
2
-1, 1, 1, 1, 2, 1, 2, 4, 5, 4, 2, 4, 3, 5, 5, 3, 5, 3, 2, 1, 3, 2, 3, 4, 3, 4, 3, 1, 3, 1, 2, 1, 4, 6, 3, 3, 5, 1, 2, 6, 6, 5, 1, 5, 2, 4, 4, 2, 1, 1, 8, 4, 2, 2, 3, 3, 3, 1, 6, 2, 4, 1, 1, 5, 3, 2, 3, 6, 1, 2, 2, 5, 2, 4, 2, 5, 5, 2, 5, 13, 5, 1, 2, 2, 2, 7, 4, 1, 5, 1, 2, 3, 4, 4, 4, 7, 3, 1, 2, 2, 2, 2, 2, 4
OFFSET
1,5
COMMENTS
What is a(15632)? - Sean A. Irvine, Jan 28 2025
a(15632) = a(15662) = 6330. - Michael S. Branicky, Jan 28 2025
LINKS
EXAMPLE
a(8) = 4 because 8 -> 25 -> 39 -> 50 -> 101.
PROG
(Python)
from math import prod
from gmpy2 import is_prime
def pod(n): return prod(map(int, str(n)))
def f(n): return 2*n - pod(n) - 1 if n&1 else 2*n + pod(n) + 1
def a(n):
seen, c, n = {n}, 1, f(n)
while not is_prime(n):
if n in seen:
return -1
seen.add(n)
c, n = c+1, f(n)
return c
print([a(n) for n in range(1, 105)]) # Michael S. Branicky, Jan 28 2025
CROSSREFS
Cf. A074808.
Sequence in context: A301364 A309503 A057061 * A307729 A245660 A034804
KEYWORD
base,sign
AUTHOR
Jason Earls, Sep 08 2002
EXTENSIONS
a(1) changed to -1 by Sean A. Irvine, Jan 28 2025
STATUS
approved