OFFSET
1,2
LINKS
Alvin Hoover Belt, Table of n, a(n) for n = 1..75
FORMULA
a(n+1) = a(n)||2 if n+1 is prime, otherwise a(n+1) = a(n)||4 where || is concatenation.
MATHEMATICA
nxt[{n_, a_}]:={n+1, If[PrimeQ[n+1], 10a+2, 10a+4]}; NestList[nxt, {1, 1}, 20][[All, 2]] (* Harvey P. Dale, Jan 16 2023 *)
PROG
(Python)
from sympy import isprime
def a(n): return 1 if n<2 else int(str(a(n - 1)) + "2") if isprime(n) else int(str(a(n - 1)) + "4")
print([a(n) for n in range(1, 51)]) # Indranil Ghosh, Apr 12 2017
CROSSREFS
KEYWORD
base,easy,nonn
AUTHOR
Amarnath Murthy, Nov 06 2005
EXTENSIONS
Corrected and extended by Alvin Hoover Belt, Mar 24 2008
Name edited by Jon E. Schoenfield, Mar 20 2021
STATUS
approved