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

A139101
Numbers that show the distribution of prime numbers up to the n-th prime minus 1, using "0" for primes and "1" for nonprime numbers.
11
1, 10, 1001, 100101, 1001010111, 100101011101, 1001010111010111, 100101011101011101, 1001010111010111010111, 1001010111010111010111011111, 100101011101011101011101111101, 100101011101011101011101111101011111, 1001010111010111010111011111010111110111
OFFSET
1,2
COMMENTS
a(n) has A000040(n)-1 digits, n-1 digits "0" and A000040(n)-n digits "1".
MATHEMATICA
Table[ sum = 0; For[i = 1, i <= Prime[n] - 1 , i++, sum = sum*2;
If[! PrimeQ[i], sum++]]; IntegerString[sum, 2], {n, 1, 13}] (* Robert Price, Apr 03 2019 *)
PROG
(PARI) a(n) = fromdigits(vector(prime(n)-1, k, !isprime(k)), 10); \\ Michel Marcus, Apr 04 2019
(Python)
from sympy import isprime, prime
def a(n): return int("".join(str(1-isprime(i)) for i in range(1, prime(n))))
print([a(n) for n in range(1, 14)]) # 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))
if isprime(k+1):
yield an
print(list(islice(agen(), 13))) # Michael S. Branicky, Jan 10 2022
CROSSREFS
Binary representation of A139102.
Subset of A118256.
Sequence in context: A215023 A071925 A346434 * A015482 A288582 A104486
KEYWORD
nonn,base
AUTHOR
Omar E. Pol, Apr 08 2008
STATUS
approved