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”).

A118256
Concatenation for i=1 to n of A005171(i); also A118255 in base 2.
8
1, 10, 100, 1001, 10010, 100101, 1001010, 10010101, 100101011, 1001010111, 10010101110, 100101011101, 1001010111010, 10010101110101, 100101011101011, 1001010111010111, 10010101110101110, 100101011101011101, 1001010111010111010, 10010101110101110101, 100101011101011101011
OFFSET
1,2
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..1000 (terms 1..30 from N. J. A. Sloane)
FORMULA
a(n) ~ 10^n * 0.10010101.... [Charles R Greathouse IV, Dec 27 2011]
EXAMPLE
A005171 : 1,0,0,1,0,1,0,1,1,1,0,1,0,1,1,1,0,1,0,1,1,1,0,1,1 ................
a(1)=1, a(2)=10, a(3)=100, a(4)=1001, ...
MATHEMATICA
Array[FromDigits@ Array[Boole[! PrimeQ@ #] &, #] &, 21] (* or *)
FromDigits@ IntegerDigits[#, 2] & /@ Last@ Transpose@ NestList[{#1 + 1, If[PrimeQ[#1 + 1], 2 #2, 2 #2 + 1]} & @@ # &, {1, 1}, 21] (* Michael De Vlieger, Nov 01 2016, latter after Harvey P. Dale at A118255 *)
PROG
(PARI) a(n) = sum(k=1, n, !isprime(k)*10^(n-k)); \\ Michel Marcus, Nov 01 2016
(Python)
from sympy import isprime
def a(n): return int("".join(str(1-isprime(i)) for i in range(1, n+1)))
print([a(n) for n in range(1, 22)]) # Michael S. Branicky, Jan 10 2022
(Python) # faster version for initial segment of sequence
from sympy import isprime
from itertools import count, islice
def agen(): # generator of terms
an = 0
for k in count(1):
an = 10 * an + int(not isprime(k))
yield an
print(list(islice(agen(), 21))) # Michael S. Branicky, Jan 10 2022
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Pierre CAMI, Apr 19 2006
EXTENSIONS
Corrected by Omar E. Pol, Nov 08 2007
STATUS
approved