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-7 of 7 results.

A007090 Numbers in base 4.

Original entry on oeis.org

0, 1, 2, 3, 10, 11, 12, 13, 20, 21, 22, 23, 30, 31, 32, 33, 100, 101, 102, 103, 110, 111, 112, 113, 120, 121, 122, 123, 130, 131, 132, 133, 200, 201, 202, 203, 210, 211, 212, 213, 220, 221, 222, 223, 230, 231, 232, 233, 300, 301, 302, 303, 310, 311, 312, 313, 320, 321, 322, 323, 330, 331, 332, 333
Offset: 0

Views

Author

Keywords

Comments

Nonnegative integers with no decimal digit > 3. Thus nonnegative integers in base 10 whose tripling (trebling) by normal addition or multiplication requires no carry operation. - Rick L. Shepherd, Jun 25 2009
Interpreted in base 10: a(x)+a(y) = a(z) => x+y = z. The converse is not true in general. - Karol Bacik, Sep 27 2012

References

  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Cf. A007608, A000042, A007088 (base 2), A007089 (base 3), A007091 (base 5), A007092 (base 6), A007093 (base 7), A007094 (base 8), A007095 (base 9), A193890, A107715.

Programs

  • Haskell
    a007090 0 = 0
    a007090 n = 10 * a007090 n' + m where (n', m) = divMod n 4
    -- Reinhard Zumkeller, Apr 08 2013, Aug 11 2011
  • Maple
    A007090 := proc(n) local l: if(n=0)then return 0: fi: l:=convert(n,base,4): return op(convert(l,base,10,10^nops(l))): end: seq(A007090(n),n=0..54); # Nathaniel Johnston, May 06 2011
  • Mathematica
    Table[ FromDigits[ IntegerDigits[n, 4]], {n, 0, 60}]
  • PARI
    a(n)=if(n<1,0,if(n%4,a(n-1)+1,10*a(n/4)))
    
  • PARI
    A007090(n)=sum(i=1,#n=digits(n,4),n[i]*10^(#n-i)) \\ M. F. Hasler, Jul 25 2015 (Corrected by Jinyuan Wang, Oct 02 2019)
    
  • PARI
    apply( A007090(n)=fromdigits(digits(n,4)), [0..66]) \\ M. F. Hasler, Nov 18 2019
    

Formula

a(n) = Sum_{d(i)*10^i: i=0, 1, ..., m}, where Sum_{d(i)*4^i: i=0, 1, ..., m} is the base 4 representation of n.
a(0) = 0, a(n) = 10*a(n/4) if n==0 (mod 4), a(n) = a(n-1)+1 otherwise. - Benoit Cloitre, Dec 22 2002

A062339 Primes whose sum of digits is 4.

Original entry on oeis.org

13, 31, 103, 211, 1021, 1201, 2011, 3001, 10111, 20011, 20101, 21001, 100003, 102001, 1000003, 1011001, 1020001, 1100101, 2100001, 10010101, 10100011, 20001001, 30000001, 101001001, 200001001, 1000000021, 1000001011, 1000010101, 1000020001, 1000200001, 1002000001, 1010000011
Offset: 1

Views

Author

Amarnath Murthy, Jun 21 2001

Keywords

Comments

Is this sequence (and its brothers A062337, A062341 and A062343) infinite?
10^A049054(m)+3 and 3*10^A056807(m)+1 are subsequences. A107715 (primes containing only digits from set {0,1,2,3}) is a supersequence. Terms not containing the digit 3 are either terms of A020449 (primes that contain digits 0 and 1 only) or of A106100 (primes with maximal digit 2) - and thus terms of these sequences' union A036953 (primes containing only digits from set {0,1,2}). - Rick L. Shepherd, May 23 2005

Examples

			3001 is a prime with sum of digits = 4, hence belongs to the sequence.
		

Crossrefs

Subsequence of A062338, A107288, and A107715 (primes with digits <= 3).
A159352 is a subsequence.
Cf. A000040 (primes), A052218 (digit sum = 4), A061239 (primes == 4 (mod 9)).
Cf. Primes p with digital sum equal to k: {2, 11 and 101} for k=2; this sequence (k=4), A062341 (k=5), A062337 (k=7), A062343 (k=8), A107579 (k=10), A106754 (k=11), A106755 (k=13), A106756 (k=14), A106757 (k=16), A106758 (k=17), A106759 (k=19), A106760 (k=20), A106761 (k=22), A106762 (k=23), A106763 (k=25), A106764 (k=26), A048517 (k=28), A106766 (k=29), A106767 (k=31), A106768 (k=32), A106769 (k=34), A106770 (k=35), A106771 (k=37), A106772 (k=38), A106773 (k=40), A106774 (k=41), A106775 (k=43), A106776 (k=44), A106777 (k=46), A106778 (k=47), A106779 (k=49), A106780 (k=50), A106781 (k=52), A106782 (k=53), A106783 (k=55), A106784 (k=56), A106785 (k=58), A106786 (k=59), A106787 (k=61), A107617 (k=62), A107618 (k=64), A107619 (k=65), A106807 (k=67), A244918 (k=68), A181321 (k=70).
Cf. A049054 (10^k+3 is prime), A159352 (these primes).
Cf. A056807 (3*10^k+1 is prime), A259866 (these primes).
Cf. A020449 (primes with digits 0 and 1), A036953 (primes with digits <= 2), A106100 (primes with largest digit = 2), A069663, A069664 (smallest resp. largest n-digit prime with minimum digit sum).

Programs

  • Magma
    [p: p in PrimesUpTo(800000000) | &+Intseq(p) eq 4]; // Vincenzo Librandi, Jul 08 2014
  • Maple
    N:= 20: # to get all terms < 10^N
    B[1]:= {1}:
    B[2]:= {2}:
    B[3]:= {3}:
    A:= {}:
    for d from 2 to N do
       B[4]:= map(t -> 10*t+1,B[3]) union  map(t -> 10*t+3,B[1]);
       B[3]:= map(t -> 10*t, B[3]) union map(t -> 10*t+1,B[2]) union map(t -> 10*t+2,B[1]);
       B[2]:= map(t -> 10*t, B[2]) union map(t -> 10*t+1,B[1]);
       B[1]:= map(t -> 10*t, B[1]);
       A:= A union select(isprime,B[4]);
    od:
    sort(convert(A,list)); # Robert Israel, Dec 28 2015
  • Mathematica
    Union[FromDigits/@Select[Flatten[Table[Tuples[{0,1,2,3},k],{k,9}],1],PrimeQ[FromDigits[#]]&&Total[#]==4&]] (* Jayanta Basu, May 19 2013 *)
    FromDigits/@Select[Tuples[{0,1,2,3},10],Total[#]==4&&PrimeQ[FromDigits[#]]&] (* Harvey P. Dale, Jul 23 2025 *)
  • PARI
    for(a=1,20,for(b=0,a,for(c=0,b,if(isprime(k=10^a+10^b+10^c+1),print1(k", "))))) \\ Charles R Greathouse IV, Jul 26 2011
    
  • PARI
    select( {is_A062339(p,s=4)=sumdigits(p)==s&&isprime(p)}, primes([1,10^7])) \\ 2nd optional parameter for similar sequences with other digit sums. M. F. Hasler, Mar 09 2022
    
  • PARI
    A062339_upto_length(L,s=4,a=List(),u=[10^(L-k)|k<-[1..L]])=forvec(d=[[1,L]|i<-[1..s]], isprime(p=vecsum(vecextract(u,d))) && listput(a,p),1); Vecrev(a) \\ M. F. Hasler, Mar 09 2022
    

Formula

Intersection of A052218 (digit sum 4) and A000040 (primes). - M. F. Hasler, Mar 09 2022

Extensions

Corrected and extended by Larry Reeves (larryr(AT)acm.org), Jul 06 2001
More terms from Rick L. Shepherd, May 23 2005
More terms from Lekraj Beedassy, Dec 19 2007

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

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

Original entry on oeis.org

3, 11, 13, 31, 101, 103, 113, 131, 311, 313, 331, 1013, 1031, 1033, 1103, 1301, 1303, 3001, 3011, 3301, 3313, 3331, 10103, 10111, 10133, 10301, 10303, 10313, 10331, 10333, 11003, 11113, 11131, 11311, 13001, 13003, 13033, 13103, 13313, 13331, 30011, 30013, 30103, 30113, 30133, 30313, 31013, 31033, 31333, 33013
Offset: 1

Views

Author

M. F. Hasler, Jul 25 2015

Keywords

Comments

A subsequence of A107715 and of A111488.
Number of terms < 10^n: 1, 4, 11, 22, 54, 118, 293, 691, 1837, 4871, 13321, 36042, 98325, 272237, 757080, .... - Robert G. Wilson v, Jul 26 2015

Crossrefs

Programs

  • Magma
    [p: p in PrimesUpTo(10^5) | Set(Intseq(p)) subset [0, 1, 3]]; // Vincenzo Librandi, Jul 26 2015
  • Mathematica
    Select[ FromDigits@# & /@ Tuples[{0, 1, 3}, 5], PrimeQ] (* Robert G. Wilson v, Jul 26 2015 *)
    Select[Prime[Range[4 10^3]], Complement[IntegerDigits[#], {0, 1, 3}]=={} &] (* Vincenzo Librandi, Jul 26 2015 *)
  • PARI
    A260044={(n,show=0,L=[0,1,3])->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)))}
    

A065722 Primes that when written in base 4, then reinterpreted in base 10, again give primes.

Original entry on oeis.org

2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 37, 43, 47, 53, 61, 71, 73, 79, 83, 97, 103, 107, 109, 113, 131, 149, 151, 157, 163, 167, 181, 191, 193, 197, 227, 233, 241, 251, 277, 293, 307, 311, 313, 317, 349, 359, 373, 389, 401, 419, 421, 433, 443, 449, 463, 467, 503
Offset: 1

Views

Author

Patrick De Geest, Nov 15 2001

Keywords

Comments

In general rebase notation (Marc LeBrun): p4 = (4) [p] (10).

Examples

			The decimal prime 29 in base 4 is 131 which is again a prime in base 10.
E.g., 509_10 = 13331_4 is prime but also 13331_10.
		

Crossrefs

Programs

  • Maple
    A007090 := proc(n) local b4digs ; b4digs := convert(n,base,4) ; add( op(i,b4digs)*10^(i-1),i=1..nops(b4digs)) ; end: isA065722 := proc(n) local rebase ; if isprime(n) then rebase := A007090(n) ; RETURN(isprime(rebase)) ; else RETURN(false) ; fi ; end: for n from 1 to 1000 do p := ithprime(n) : if isA065722(p) then printf("%d, ",p) ; fi : od : # R. J. Mathar, Jun 15 2007
  • Mathematica
    Select[ Range[505], PrimeQ[ # ] && PrimeQ[ FromDigits[ IntegerDigits[ #, 4]]] & ]
  • PARI
    isok(p)={ isprime(p) && isprime(fromdigits(digits(p,4))) } \\ Harry J. Smith, Oct 27 2009

Formula

Numbers n such that A049084(n)>0 and A049084(A007090(n))>0. - R. J. Mathar, Jun 15 2007

Extensions

Edited by N. J. A. Sloane, Jul 02 2008 at the suggestion of R. J. Mathar

A193890 Primes p such that replacing any single decimal digit d with 3*d produces another prime (obviously p can contain only digits 0, 1, 2 or 3).

Original entry on oeis.org

11, 311, 1301, 10133, 1030031
Offset: 1

Views

Author

Arkadiusz Wesolowski, Aug 08 2011

Keywords

Comments

These numbers do not occur in A050249 (weakly associated primes).
p cannot contain digits 1 and 2 at the same time due to divisibility by 3.
No more terms < 10^9. [Reinhard Zumkeller, Aug 11 2011]
No more terms < 10^14. - Arkadiusz Wesolowski, Feb 08 2012
No more terms < 10^18. - Giovanni Resta, Feb 23 2013
No more terms < 10^22. - Jan van Delden, Mar 06 2016
The number of occurrences of the digit 1 or 2 is congruent to 2 (mod 3). - Robert Israel, Mar 07 2016

Examples

			1301 belongs to this sequence because 1303, 1301, 1901 and 3301 are all prime.
		

Crossrefs

Programs

  • Haskell
    import Data.List (inits, tails)
    a193890 n = a193890_list !! (n-1)
    a193890_list = filter f a107715_list where
       f n = (all ((== 1) . a010051) $
                   zipWith (\ins (t:tns) -> read $ (ins ++ x3 t ++ tns))
                           (init $ inits $ show n) (init $ tails $ show n))
           where x3 '0' = "0"
                 x3 '1' = "3"
                 x3 '2' = "6"
                 x3 '3' = "9"
    -- Reinhard Zumkeller, Aug 11 2011
    
  • Maple
    S:= NULL:
    for x from 2 to 3^10 do
       L:= convert(x, base, 3):
       if numboccur(1,L) mod 3 <> 2 then next fi;
       L1:= subs(2=3,L);
       L2:= subs(1=2,L1);
       for LL in [L1,L2] do
         y:= add(LL[i]*10^(i-1), i=1..nops(L1));
         if isprime(y) then
          good:= true;
          for j from 1 to nops(LL) do
             yp:= y + 2*LL[j]*10^(j-1);
             if not isprime(yp) then
                good:= false;
                break
             fi
          od:
          if good then S:= S, y fi;
         fi;
       od
    od:
    sort([S]); # Robert Israel, Mar 07 2016
  • Mathematica
    Select[Select[Prime@ Range[10^6], AllTrue[IntegerDigits@ #, MemberQ[{0, 1, 2, 3}, #] &] &], Function[k, AllTrue[Map[FromDigits, Map[MapAt[3 # &, IntegerDigits@ k, #] &, Range@ IntegerLength@ k]], PrimeQ]]] (* Michael De Vlieger, Mar 06 2016, Version 10 *)
  • Python
    from sympy import isprime
    from itertools import product
    A193890_list = []
    for l in range(1,10):
        for d in product('0123',repeat=l):
            p = int(''.join(d))
            if d[0] != '0' and d[-1] in ('1','3') and isprime(p):
                for i in range(len(d)):
                    d2 = list(d)
                    d2[i] = str(3*int(d[i]))
                    if not isprime(int(''.join(d2))):
                        break
                else:
                     A193890_list.append(p) # Chai Wah Wu, Aug 13 2015

A036955 Numbers whose base-4 representation is the decimal representation of a prime.

Original entry on oeis.org

2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 37, 43, 47, 53, 55, 61, 71, 73, 77, 79, 83, 91, 97, 103, 107, 109, 113, 115, 121, 131, 133, 149, 151, 157, 163, 167, 169, 181, 191, 193, 197, 203, 217, 227, 233, 241, 247, 251, 253, 275, 277, 287, 293, 299, 305, 307, 311, 313
Offset: 1

Views

Author

Patrick De Geest, Jan 04 1999

Keywords

Comments

All terms are congruent to 1 or 3 (mod 4) (except for the first one) and congruent to 1 or 5 (mod 6) (except for the first two); although not all terms are prime, as e.g., 55, 77, 91, 115, 121, 133, 169, 203, ... - M. F. Hasler, Jul 25 2015
Numbers (not necessarily prime) which are prime if written in base 4 and reinterpreted in base 10. Numbers n such that A007090(n) is in A000040. - R. J. Mathar, Jul 28 2015

Examples

			55 is in the sequence because 55_10 = 313_4 and 313_10 is prime.
313 is in the sequence because 313_10 = 10321_4 and 10321_10 is prime.
31 is not in the sequence because 31_10 = 133_4 and 133_10 = 7*19 is not prime.
		

Crossrefs

Programs

  • Mathematica
    FromDigits[IntegerDigits[#],4]&/@Select[Prime[Range[2000]],Max[ IntegerDigits[ #]]<4&] (* Harvey P. Dale, May 02 2015 *)
  • PARI
    is(n)=isprime(sum(i=1,#n=digits(n,4),n[i]*10^(#n-i))) \\ M. F. Hasler, Jul 25 2015

Extensions

Offset corrected to 1 and minor edits by M. F. Hasler, Jul 25 2015
Showing 1-7 of 7 results.