[go: up one dir, main page]

login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A113574
a(n) is the least n-digit number whose k-th digit is prime if k is prime, composite if k is composite, and 1 if k=1.
1
1, 12, 122, 1224, 12242, 122424, 1224242, 12242424, 122424244, 1224242444, 12242424442, 122424244424, 1224242444242, 12242424442424, 122424244424244, 1224242444242444, 12242424442424442, 122424244424244424
OFFSET
1,2
LINKS
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
Sequence in context: A134584 A090843 A132927 * A255307 A199592 A285807
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