A345338 Integers whose Reverse And Add trajectory reaches its first prime after a record number of iterations (at least one iteration must be performed).
1, 5, 181, 10031, 1001320
Offset: 1
Examples
a(3) = 181 because it takes 3 iterations (181 -> 362 -> 625 -> 1151 (prime)) to reach a prime, which is more than any smaller number.
Crossrefs
Cf. A056964.
Programs
-
PARI
f(n) = my(t=n, c=1); while(!isprime(t+=fromdigits(Vecrev(digits(t)))), if(gcd(t, 33)>1, return(0)); c++); c; lista(nn) = my(m); for(k=1, nn, if(f(k)>m, print1(k, ", "); m=f(k))); \\ Jinyuan Wang, Jun 15 2021
-
Python
from sympy import isprime def ra(n): s = str(n); return int(s) + int(s[::-1]) def afind(limit): record = 0 for k in range(limit+1): m, i = ra(k), 1 while not isprime(m) and m%3 != 0 and m%11 != 0: m = ra(m); i += 1 if isprime(m) and i > record: record = i; print(k, end=", ") afind(1234567) # Michael S. Branicky, Jul 03 2021
Comments