cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-10 of 13 results. Next

A385776 Primes having only {1, 2, 9} as digits.

Original entry on oeis.org

2, 11, 19, 29, 191, 199, 211, 229, 911, 919, 929, 991, 1129, 1229, 1291, 1999, 2111, 2129, 2221, 2999, 9199, 9221, 9929, 11119, 11299, 12119, 12211, 12911, 12919, 19121, 19211, 19219, 19919, 19991, 21121, 21191, 21211, 21221, 21911, 21929, 21991
Offset: 1

Views

Author

Jason Bard, Jul 09 2025

Keywords

Crossrefs

Supersequence of A020450, A020457, A020460.
Cf. A000040.

Programs

  • Magma
    [p: p in PrimesUpTo(10^6) | Set(Intseq(p)) subset [1, 2, 9]];
    
  • Mathematica
    Flatten[Table[Select[FromDigits /@ Tuples[{1, 2, 9}, n], PrimeQ], {n, 7}]]
  • PARI
    primes_with(n=50, show=0, L=[1, 2, 9])={for(d=1, 1e9, my(t, u=vector(d, i, 10^(d-i))~); forvec(v=vector(d, i, [1+!(L[1]||(i>1&&i
    				
  • Python
    from gmpy2 import is_prime
    from itertools import count, islice, product
    def primes_with(digits):  # generator of primes having only set(digits) as digits
        S, E = "".join(sorted(set(digits) - {'0'})), "".join(sorted(set(digits) & set("1379")))
        yield from (p for p in [2, 3, 5, 7] if str(p) in digits)
        yield from (t for d in count(2) for s in S for m in product(digits, repeat=d-2) for e in E if is_prime(t:=int(s+"".join(m)+e)))
    print(list(islice(primes_with("129"), 41))) # Michael S. Branicky, Jul 11 2025

A007931 Numbers that contain only 1's and 2's. Nonempty binary strings of length n in lexicographic order.

Original entry on oeis.org

1, 2, 11, 12, 21, 22, 111, 112, 121, 122, 211, 212, 221, 222, 1111, 1112, 1121, 1122, 1211, 1212, 1221, 1222, 2111, 2112, 2121, 2122, 2211, 2212, 2221, 2222, 11111, 11112, 11121, 11122, 11211, 11212, 11221, 11222, 12111, 12112, 12121, 12122
Offset: 1

Views

Author

R. Muller

Keywords

Comments

Numbers written in the dyadic system [Smullyan, Stillwell]. - N. J. A. Sloane, Feb 13 2019
Logic-binary sequence: prefix it by the empty word to have all binary words on the alphabet {1,2}.
The least binary word of length k is a(2^k - 1).
See Mathematica program for logic-binary sequence using (0,1) in place of (1,2); the sequence starts with 0,1,00,01,10. - Clark Kimberling, Feb 09 2012
A007953(a(n)) = A014701(n+1); A007954(a(n)) = A048896(n). - Reinhard Zumkeller, Oct 26 2012
a(n) is n written in base 2 where zeros are not allowed but twos are. The two distinct digits used are 1, 2 instead of 0, 1. To obtain this sequence from the "canonical" base 2 sequence with zeros allowed, just replace any 0 with a 2 and then subtract one from the group of digits situated on the left: (10-->2; 100-->12; 110-->22; 1000-->112; 1010-->122). - Robin Garcia, Jan 31 2014
For numbers made of only two different digits, see also A007088 (digits 0 & 1), A032810 (digits 2 & 3), A032834 (digits 3 & 4), A256290 (digits 4 & 5), A256291 (digits 5 & 6), A256292 (digits 6 & 7), A256340(digits 7 & 8), A256341 (digits 8 & 9), and A032804-A032816 (in other bases). Numbers with exactly two distinct (but unspecified) digits in base 10 are listed in A031955, for other bases in A031948-A031954. - M. F. Hasler, Apr 04 2015
The variant with digits {0, 1} instead of {1, 2} is obtained by deleting all initial digits in sequence A007088 (numbers written in base 2). - M. F. Hasler, Nov 03 2020

Examples

			Positive numbers may not start with 0 in the OEIS, otherwise this sequence would have been written as: 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, 100, 101, 110, 111, 0000, 0001, 0010, 0011, 0100, 0101, 0110, 0111, 1000, 1001, 1010, 1011, 1100, 1101, 1110, 1111, 00000, 00001, 00010, 00011, 00100, 00101, 00110, 00111, 01000, 01001, 01010, 01011, ...
From _Hieronymus Fischer_, Jun 06 2012: (Start)
a(10)   = 122.
a(100)  = 211212.
a(10^3) = 222212112.
a(10^4) = 1122211121112.
a(10^5) = 2111122121211112.
a(10^6) = 2221211112112111112.
a(10^7) = 11221112112122121111112.
a(10^8) = 12222212122221111211111112.
a(10^9) = 22122211221212211212111111112. (End)
		

References

  • J.-P. Allouche and J. Shallit, Automatic Sequences, Cambridge Univ. Press, 2003, p. 2. - From N. J. A. Sloane, Jul 26 2012
  • K. Atanassov, On the 97th, 98th and the 99th Smarandache Problems, Notes on Number Theory and Discrete Mathematics, Sophia, Bulgaria, Vol. 5 (1999), No. 3, 89-93.
  • R. M. Smullyan, Theory of Formal Systems, Princeton, 1961.
  • John Stillwell, Reverse Mathematics, Princeton, 2018. See p. 90.

Crossrefs

Cf. A007932 (digits 1-3), A059893, A045670, A052382 (digits 1-9), A059939, A059941, A059943, A032924, A084544, A084545, A046034 (prime digits 2,3,5,7), A089581, A084984 (no prime digits); A001742, A001743, A001744: loops; A202267 (digits 0, 1 and primes), A202268 (digits 1,4,6,8,9), A014261 (odd digits), A014263 (even digits).
Cf. A007088 (digits 0 & 1), A032810 (digits 2 & 3), A032834 (digits 3 & 4), A256290 (digits 4 & 5), A256291 (digits 5 & 6), A256292 (digits 6 & 7), A256340 (digits 7 & 8), A256341 (digits 8 & 9), and A032804-A032816 (in other bases).
Cf. A020450 (primes).

Programs

  • Haskell
    a007931 n = f (n + 1) where
       f x = if x < 2 then 0 else (10 * f x') + m + 1
         where (x', m) = divMod x 2
    -- Reinhard Zumkeller, Oct 26 2012
    
  • Magma
    [n: n in [1..100000] | Set(Intseq(n)) subset {1,2}]; // Vincenzo Librandi, Aug 19 2016
    
  • Maple
    # Maple program to produce the sequence:
    a:= proc(n) local m, r, d; m, r:= n, 0;
          while m>0 do d:= irem(m, 2, 'm');
            if d=0 then d:=2; m:= m-1 fi;
            r:= d, r
          od; parse(cat(r))/10
        end:
    seq(a(n), n=1..100);  # Alois P. Heinz, Aug 26 2016
    # Maple program to invert this sequence: given a(n), it returns n. - N. J. A. Sloane, Jul 09 2012
    invert7931:=proc(u)
    local t1,t2,i;
    t1:=convert(u,base,10);
    [seq(t1[i]-1,i=1..nops(t1))];
    [op(%),1];
    t2:=convert(%,base,2,10);
    add(t2[i]*10^(i-1),i=1..nops(t2))-1;
    end;
  • Mathematica
    f[n_] := FromDigits[Rest@IntegerDigits[n + 1, 2] + 1]; Array[f, 42] (* Robert G. Wilson v Sep 14 2006 *)
    (* Next, A007931 using (0,1) instead of (1,2) *)
    d[n_] := FromDigits[Rest@IntegerDigits[n + 1, 2] + 1]; Array[FromCharacterCode[ToCharacterCode[ToString[d[#]]] - 1] &, 100] (* Peter J. C. Moses, at request of Clark Kimberling, Feb 09 2012 *)
    Flatten[Table[FromDigits/@Tuples[{1,2},n],{n,5}]] (* Harvey P. Dale, Sep 13 2014 *)
  • PARI
    apply( {A007931(n)=fromdigits([d+1|d<-binary(n+1)[^1]])}, [1..44]) \\ M. F. Hasler, Nov 03 2020, replacing older code from Mar 26 2015
    
  • PARI
    /* inverse function */ apply( {A007931_inv(N)=fromdigits([d-1|d<-digits(N)],2)+2<M. F. Hasler, Nov 09 2020
    
  • Python
    def a(n): return int(bin(n+1)[3:].replace('1', '2').replace('0', '1'))
    print([a(n) for n in range(1, 45)]) # Michael S. Branicky, May 13 2021
    
  • Python
    def A007931(n): return int(s:=bin(n+1)[3:])+(10**(len(s))-1)//9 # Chai Wah Wu, Jun 13 2025

Formula

To get a(n), write n+1 in base 2, remove initial 1, add 1 to all remaining digits: e.g., eleven (11) in base 2 is 1011; remove initial 1 and add 1 to remaining digits: a(10)=122. - Clark Kimberling, Mar 11 2003
Conversely, given a(n), to get n: subtract 1 from all digits, prefix with an initial 1, convert this binary number to base 10, subtract 1. E.g., a(6)=22 -> 11 -> 111 -> 7 -> 6. - N. J. A. Sloane, Jul 09 2012
a(n) = A053645(n+1)+A002275(A000523(n)) = a(n-2^b(n))+10^b(n) where b(n) = A059939(n) = floor(log_2(n+1)-1). - Henry Bottomley, Feb 14 2001
From Hieronymus Fischer, Jun 06 2012 and Jun 08 2012: (Start)
The formulas are designed to calculate base-10 numbers only using the digits 1 and 2.
a(n) = Sum_{j=0..m-1} (1 + b(j) mod 2)*10^j, where m = floor(log_2(n+1)), b(j) = floor((n+1-2^m)/(2^j)).
Special values:
a(k*(2^n-1)) = k*(10^n-1)/9, k= 1,2.
a(3*2^n-2) = (11*10^n-2)/9 = 10^n+2*(10^n-1)/9.
a(2^n-2) = 2*(10^(n-1)-1)/9, n>1.
Inequalities:
a(n) <= (10^log_2(n+1)-1)/9, equality holds for n=2^k-1, k>0.
a(n) > (2/10)*(10^log_2(n+1)-1)/9.
Lower and upper limits:
lim inf a(n)/10^log_2(n) = 1/45, for n --> infinity.
lim sup a(n)/10^log_2(n) = 1/9, for n --> infinity.
G.f.: g(x) = (1/(x(1-x)))*sum_{j=0..infinity} 10^j* x^(2*2^j)*(1 + 2 x^2^j)/(1 + x^2^j).
Also: g(x) = (1/(1-x))*(h_(2,0)(x) + h_(2,1)(x) - 2*h_(2,2)(x)), where h_(2,k)(x) = sum_{j>=0} 10^j*x^(2^(j+1)-1)*x^(k*2^j)/(1-x^2^(j+1)).
Also: g(x) = (1/(1-x)) sum_{j>=0} (1 - 3(x^2^j)^2 + 2(x^2^j)^3)*x^2^j*f_j(x)/(1-x^2^j), where f_j(x) = 10^j*x^(2^j-1)/(1-(x^2^j)^2). The f_j obey the recurrence f_0(x) = 1/(1-x^2), f_(j+1)(x) = 10x*f_j(x^2). (End)

Extensions

Some crossrefs added by Hieronymus Fischer, Jun 06 2012
Edited by M. F. Hasler, Mar 26 2015

A036302 Composite numbers k such that the digits of the prime factors of k are either 1 or 2.

Original entry on oeis.org

4, 8, 16, 22, 32, 44, 64, 88, 121, 128, 176, 242, 256, 352, 422, 484, 512, 704, 844, 968, 1024, 1331, 1408, 1688, 1936, 2048, 2321, 2662, 2816, 3376, 3872, 4096, 4222, 4442, 4642, 5324, 5632, 6752, 7744, 8192, 8444, 8884, 9284, 10648, 11264, 13504, 14641, 15488, 16384
Offset: 1

Views

Author

Patrick De Geest, Dec 15 1998

Keywords

Comments

All terms are a product of at least two terms of A020450. - Michel Marcus, Oct 02 2020

Examples

			422 = 2 * 211 is in the sequence as the digits of its prime factors 2 and 211 are either 1 or 2. - _David A. Corneth_, Sep 26 2020
		

Crossrefs

Cf. A003596 (a subsequence), A020450, A036303-A036325.

Programs

  • Magma
    [k:k in [2..15000]|  not IsPrime(k) and forall{a: a in PrimeDivisors(k)|Intseq(a) subset {1,2}}]; // Marius A. Burtea, Oct 08 2019
  • Mathematica
    Select[Range[2,14650],!PrimeQ[#] && Complement[Flatten[IntegerDigits[First/@FactorInteger[#]]],{1,2}]=={} &] (* Jayanta Basu, May 25 2013 *)

Formula

Sum_{n>=1} 1/a(n) = Product_{p in A020450} p/(p-1) - Sum_{p in A020450} 1/p - 1 = 0.616325... - Amiram Eldar, Oct 14 2020

A036953 Primes having only {0, 1, 2} as digits.

Original entry on oeis.org

2, 11, 101, 211, 1021, 1201, 2011, 2111, 2221, 10111, 10211, 12011, 12101, 12211, 20011, 20021, 20101, 20201, 21001, 21011, 21101, 21121, 21211, 21221, 22111, 101021, 101111, 101221, 102001, 102101, 102121, 110221, 111121, 111211, 112111
Offset: 1

Views

Author

Patrick De Geest, Jan 04 1999

Keywords

Comments

Number of n-digit terms d(n) = (1, 1, 2, 5, 16, 34, 76, 194, 543, 1469, 4094, 11017, ...); e.g., there are five 4-digit terms: 1021, 1201, 2011, 2111, 2221, hence d(4) = 5. - Zak Seidov, Jun 30 2013
Also, primes in A007089. - M. F. Hasler, Jul 25 2015

Crossrefs

Programs

  • Mathematica
    Select[FromDigits/@Tuples[{0,1,2},6],PrimeQ] (* Harvey P. Dale, Jul 11 2017 *)
  • PARI
    lista(n) = {forprime(p=2, n, if (vecmax(digits(p)) <= 2, print1(p, ", ")))} \\ Michel Marcus, Aug 02 2014
    
  • PARI
    A036953={(n,show=0)->for(d=1,1e9,my(u=vector(d,i,10^(d-i))~);forvec(v=vector(d,i,if(i>1,if(iM. F. Hasler, Jul 25 2015
  • Python
    from gmpy2 import digits
    from sympy import isprime
    [int(digits(n,3)) for n in range(1000) if isprime(int(digits(n,3)))] # Chai Wah Wu, Jul 31 2014
    

Extensions

Edited by M. F. Hasler, Jul 25 2015

A260267 Primes having only {1, 2, 4} as digits.

Original entry on oeis.org

2, 11, 41, 211, 241, 421, 2111, 2141, 2221, 2411, 2441, 4111, 4211, 4241, 4421, 4441, 11411, 12211, 12241, 12421, 14221, 14411, 21121, 21211, 21221, 22111, 22441, 24121, 24421, 41141, 41221, 41411, 42221, 44111, 44221, 111121, 111211, 112111, 112121, 112241
Offset: 1

Views

Author

Vincenzo Librandi, Jul 23 2015

Keywords

Comments

A020450 and A020452 are subsequences.
All terms but the first one end with a digit "1". - M. F. Hasler, Jul 26 2015

Crossrefs

Cf. similar sequences listed in A260266.

Programs

  • Magma
    [p: p in PrimesUpTo(4*10^5) | Set(Intseq(p)) subset [1, 4, 2]];
    
  • Mathematica
    Select[Prime[Range[3 10^4]], Complement[IntegerDigits[#], {1, 4, 2}]=={} &]
  • PARI
    A260267(n=50,show=0)={for(d=1,1e9,my(t,u=vector(d,i,10^(d-i))~);forvec(v=vector(d,i,[0,if(iM. F. Hasler, Jul 25 2015

A260266 Primes having only {0, 1, 4} as digits.

Original entry on oeis.org

11, 41, 101, 401, 4001, 4111, 4441, 10111, 10141, 11411, 14011, 14401, 14411, 40111, 41011, 41141, 41411, 44041, 44101, 44111, 100411, 101111, 101141, 101411, 110441, 114001, 114041, 140111, 140401, 140411, 141041, 141101, 400441, 401101, 401411, 404011
Offset: 1

Views

Author

Vincenzo Librandi, Jul 22 2015

Keywords

Comments

A020449 and A020452 are subsequences.
All terms end with a digit "1". - M. F. Hasler, Jul 26 2015

Crossrefs

Primes that contain only digits among {1,4,k}: this sequence (k=0), A260267 (k=2), A199341 (k=3), A260268 (k=5), A260269 (k=6), A079651 (k=7), A260270 (k=8), A260271 (k=9).

Programs

  • Magma
    [p: p in PrimesUpTo(5*10^5) | Set(Intseq(p)) subset [1, 4, 0]];
    
  • Mathematica
    Select[Prime[Range[4 10^4]], Complement[IntegerDigits[#], {1, 4, 0}]=={} &]
  • PARI
    A260266(n=50,show=0)={for(d=1,1e9,my(t,u=vector(d,i,10^(d-i))~);forvec(v=vector(d,i,[i==1||i==d,1+(iM. F. Hasler, Jul 25 2015

A260889 Primes having only {1, 2, 7} as digits.

Original entry on oeis.org

2, 7, 11, 17, 71, 127, 211, 227, 271, 277, 727, 1117, 1171, 1217, 1277, 1721, 1777, 2111, 2221, 2711, 2777, 7121, 7127, 7177, 7211, 7717, 7727, 11117, 11171, 11177, 11717, 11777, 12211, 12227, 12277, 12721, 17117, 21121, 21211, 21221, 21227, 21277, 21727
Offset: 1

Views

Author

Vincenzo Librandi, Aug 04 2015

Keywords

Comments

A020450, A020455 and A020459 are subsequences.

Crossrefs

Cf. Primes that contain only the digits (k,1,7): A199327 (k=0), this sequence (k=2), A260379 (k=3), A079651 (k=4), A260828 (k=5), A260891 (k=6), A260892 (k=8), A260893 (k=9).

Programs

  • Magma
    [p: p in PrimesUpTo(3*10^4) | Set(Intseq(p)) subset [1, 2, 7]];
  • Mathematica
    Select[Prime[Range[2 10^5]], Complement[IntegerDigits[#], {1, 2, 7}] == {} &]
    Table[Select[FromDigits/@Tuples[{1,2,7},n],PrimeQ],{n,5}]//Flatten (* Harvey P. Dale, Apr 12 2018 *)

A385774 Primes having only {1, 2, 6} as digits.

Original entry on oeis.org

2, 11, 61, 211, 661, 1621, 2111, 2161, 2221, 2621, 6121, 6211, 6221, 6661, 11161, 11261, 11621, 12161, 12211, 12611, 16111, 16661, 21121, 21211, 21221, 21611, 21661, 22111, 22621, 26111, 26161, 26261, 61121, 61211, 61261, 66161, 66221, 111121, 111211
Offset: 1

Views

Author

Jason Bard, Jul 09 2025

Keywords

Crossrefs

Supersequence of A020450, A020454.

Programs

  • Magma
    [p: p in PrimesUpTo(10^6) | Set(Intseq(p)) subset [1, 2, 6]];
    
  • Mathematica
    Flatten[Table[Select[FromDigits /@ Tuples[{1, 2, 6}, n], PrimeQ], {n, 7}]]
  • PARI
    primes_with(, 1, [1, 2, 6]) \\ uses function in A385776
  • Python
    print(list(islice(primes_with("126"), 41))) # uses function/imports in A385776
    

A385775 Primes having only {1, 2, 8} as digits.

Original entry on oeis.org

2, 11, 181, 211, 281, 811, 821, 881, 1181, 1811, 2111, 2221, 2281, 8111, 8221, 8821, 11821, 12211, 12281, 12821, 18121, 18181, 18211, 21121, 21211, 21221, 21821, 21881, 22111, 22811, 28111, 28181, 28211, 81181, 81281, 82811, 88211, 88811, 111121
Offset: 1

Views

Author

Jason Bard, Jul 09 2025

Keywords

Crossrefs

Supersequence of A020450, A020456.

Programs

  • Magma
    [p: p in PrimesUpTo(10^6) | Set(Intseq(p)) subset [1, 2, 8]];
    
  • Mathematica
    Flatten[Table[Select[FromDigits /@ Tuples[{1, 2, 8}, n], PrimeQ], {n, 7}]]
  • PARI
    primes_with(, 1, [1, 2, 8]) \\ uses function in A385776
  • Python
    print(list(islice(primes_with("128"), 41))) # uses function/imports in A385776
    

A111488 Primes having only {0, 1, 3, 6} as digits.

Original entry on oeis.org

3, 11, 13, 31, 61, 101, 103, 113, 131, 163, 311, 313, 331, 601, 613, 631, 661, 1013, 1031, 1033, 1061, 1063, 1103, 1163, 1301, 1303, 1361, 1601, 1613, 1663, 3001, 3011, 3061, 3163, 3301, 3313, 3331, 3361, 3613, 3631, 6011, 6101, 6113, 6131, 6133, 6163
Offset: 1

Views

Author

Jonathan Vos Post, Nov 15 2005

Keywords

Comments

Includes all repunit primes (A004022). Conjecture: an infinite sequence. Note twin primes: (11, 13), (101, 103), (311, 313), (1031, 1033), (1061, 1063), (1301, 1303), (6131, 6133), (10301, 10303), (10331, 10333), (13001, 13003).
In other words, primes with digits in the set {0,1,3,6}. - M. F. Hasler, Jul 25 2015
The number of 1's in the representation must be either 1 or 2 (mod 3), because otherwise the number would be divisible by 3 (and therefore composite). The only exception is the 3 itself. This excludes basically members of A038603. - R. J. Mathar, Jul 25 2015

Crossrefs

Programs

  • Maple
    f:= proc(x) local L,p;
      L:= subs([3=6,2=3],convert(x,base,4));
      p:= add(L[i]*10^(i-1),i=1..nops(L));
      if isprime(p) then p fi
    end proc:
    map(f, [$1..4^4]); # Robert Israel, Dec 18 2018
  • Mathematica
    Select[Prime@ Range@ 1000, SubsetQ[{0, 1, 3, 6}, IntegerDigits@ #] &] (* Michael De Vlieger, Jul 25 2015 *)
  • PARI
    A111488={(n, show=0, L=[0,1,3,6])->my(t); for(d=1,1e9,u=vector(d, i, 10^(d-i))~; forvec(v=vector(d,i,[1+(i==1&&!L[1]), #L]), ispseudoprime(t=vector(d, i, L[v[i]])*u)||next; show&print1(t", "); n--||return(t)))} \\ M. F. Hasler, Jul 25 2015

Extensions

Corrected by Ray Chandler, Nov 19 2005
Name changed by Sean A. Irvine, Jul 21 2025
Showing 1-10 of 13 results. Next