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 34 results. Next

A095741 Number of base-2 palindromic primes (A016041) in range [2^2n,2^(2n+1)].

Original entry on oeis.org

2, 2, 3, 3, 7, 12, 23, 40, 94, 142, 271, 480, 856, 1721, 3099, 5572, 10799, 20782, 39468, 72672, 139867, 274480, 520376, 986318, 1914097, 3726617, 7107443, 13682325, 26430797, 51412565, 99204128, 190457946, 372035117, 727434192, 1407026351, 2724590109, 5315491839
Offset: 1

Views

Author

Antti Karttunen, Jun 12 2004

Keywords

Comments

Note that there are no such primes in any range ]2^(2n-1),2^2n], as all even-length binary palindromes are divisible by 3 (cf. A048702).
The ratio a(n)/A036378(2n) converges as follows: 1, 0.4, 0.230769, 0.069767, 0.051095, 0.025862, 0.014268, 0.007006, 0.00461, 0.00193, 0.00101, 0.000487, 0.000235, 0.000127, 0.000061, 0.000029

Crossrefs

Bisection of the first diagonal of triangle A095759.

Programs

  • Mathematica
    palindromicQ[n_, b_:10] := TrueQ[IntegerDigits[n, b] == Reverse[IntegerDigits[n, b]]]; Table[Length[Select[Range[2^(2n), 2^(2n + 1)], palindromicQ[#, 2] && PrimeQ[#] &]], {n, 10}] (* Alonso del Arte, Jan 13 2012 *)
  • PARI
    m=vector(65536);u=vector(#m);u[1]=1;for(b=1,#m-1,c=b;e=2^floor(log(b+.5)/log(2));d=0;u[b+1]=e;while(c>0,d=d+e*(c%2);c=floor(c/2);e=e/2);m[b+1]=d);for(x=0,31,h=0;y=2^x;for(w=y,2*y-1,if(x<16,v1=4*y*w+m[w+1];v2=v1+2*y,w1=floor(w/65536);w2=w-65536*w1;v1=262144*y*w1+4*y*w2+65536*u[w1+1]/u[w2+1]*m[w2+1]+m[w1+1];v2=v1+2*y);if(isprime(v1),h++);if(isprime(v2),h++));print(2*x+3" bits: "h)) \\ Martin Raab, Jan 13 2012

Formula

a(n) = A117773(2*n+1). - Chai Wah Wu, Jul 05 2019

Extensions

a(27)-a(32) from Martin Raab, Oct 20 2015
a(33)-a(35) from Chai Wah Wu, Jul 05 2019
a(36)-a(37) from Chai Wah Wu, Jul 11 2019

A194097 Decimal expansion of the sum of the reciprocals of A016041 (primes that are binary palindromes).

Original entry on oeis.org

8, 1, 5, 7, 1, 0, 1, 9, 6, 2, 9, 0
Offset: 0

Views

Author

Kausthub Gudipati, Aug 15 2011

Keywords

Examples

			Partial sum is 0.81571010760865175... if primes up to 40 binary digits are included; partial sum is 0.8157101534554485... if summed to 42 binary digits. - _R. J. Mathar_, Aug 27 2011
Partial sum is 0.81571019628323164... for primes up to 66 bits. - _Martin Raab_, Jan 13 2012
		

Crossrefs

Extensions

a(6)-a(11) from Martin Raab, Jan 13 2012
Edited by Jon E. Schoenfield, Nov 27 2016

A164124 First differences of A016041.

Original entry on oeis.org

0, 2, 2, 10, 14, 42, 34, 20, 130, 56, 130, 750, 260, 118, 48, 168, 44, 48, 3010, 224, 76, 368, 312, 112, 230, 616, 780, 152, 160, 272, 9186, 720, 192, 1144, 176, 192, 1356, 1384, 128, 192, 720, 448, 1718, 192, 1240, 624, 320, 96, 588, 864, 720, 792, 544
Offset: 1

Views

Author

Keywords

Comments

Differences between successive primes that are palindromic in base 2.
3, 5, 7, 17, 31, 73, 107, 127, 257, 313, 443, 1193, 1453, 1571, 1619, 1787, 1831, 1879, ...

Crossrefs

Programs

  • Mathematica
    f[n_]:=FromDigits[RealDigits[n,2][[1]]]==FromDigits[Reverse[RealDigits[n,2][[1]]]]; a=3;lst={};Do[p=Prime[n];If[f[p],AppendTo[lst,p-a];a=p],{n,2,8!,1}];lst
    Join[{0},Differences[Select[Prime[Range[5000]],IntegerDigits[#,2]== Reverse[ IntegerDigits[ #,2]]&]]] (* Harvey P. Dale, Aug 17 2024 *)

Extensions

Definition corrected by Charles R Greathouse IV, Oct 08 2009

A002385 Palindromic primes: prime numbers whose decimal expansion is a palindrome.

Original entry on oeis.org

2, 3, 5, 7, 11, 101, 131, 151, 181, 191, 313, 353, 373, 383, 727, 757, 787, 797, 919, 929, 10301, 10501, 10601, 11311, 11411, 12421, 12721, 12821, 13331, 13831, 13931, 14341, 14741, 15451, 15551, 16061, 16361, 16561, 16661, 17471, 17971, 18181, 18481, 19391, 19891, 19991
Offset: 1

Views

Author

Keywords

Comments

Every palindrome with an even number of digits is divisible by 11, so 11 is the only member of the sequence with an even number of digits. - David Wasserman, Sep 09 2004
This holds in any number base A006093(n), n>1. - Lekraj Beedassy, Mar 07 2005 and Dec 06 2009
The log-log plot shows the fairly regular structure of these numbers. - T. D. Noe, Jul 09 2013
Conjecture: The only primes with palindromic prime indices that are palindromic primes themselves are 3, 5 and 11. Tested for the primes with the first 8000000 palindromic prime indices. - Ivan N. Ianakiev, Oct 10 2014
It follows from the above conjecture that 2 is the only k such that k, prime(k), prime(m) = k + prime(k) and m are all palindromic primes. - Ivan N. Ianakiev, Mar 17 2025
Banks, Hart, and Sakata derive a nontrivial upper bound for the number of prime palindromes n <= x as x -> oo. It follows that almost all palindromes are composite. The results hold in any base. The authors use Weil's bound for Kloosterman sums. - Jonathan Sondow, Jan 02 2018
Number of terms < 100^k, k >= 1: 5, 20, 113, 781, 5953, 47995, 401698, .... - Robert G. Wilson v, Jan 03 2018, corrected by M. F. Hasler, Dec 19 2024
Initially the above comment listed 4, 20, 113, ... which is the number of terms less than 10, 1000, 10^5, ..., i.e., up to 10^(2k-1), k >= 1. The number of terms < 10^k are the cumulative sums of A016115(n) (number of prime palindromes with n digits) up to n = k. - M. F. Hasler, Dec 19 2024

References

  • A. H. Beiler, Recreations in the Theory of Numbers, Dover, NY, 1964, p. 228.
  • Paulo Ribenboim, The Little Book of Bigger Primes, Springer-Verlag NY 2004. See pp. 120-121.
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

A007500 = this sequence union A006567.
Subsequence of A188650; A188649(a(n)) = a(n); see A033620 for multiplicative closure. [Reinhard Zumkeller, Apr 11 2011]
Cf. A016041, A029732, A069469, A117697, A046942, A032350 (Palindromic nonprime numbers).
Cf. A016115 (number of prime palindromes with n digits).

Programs

  • GAP
    Filtered([1..20000],n->IsPrime(n) and ListOfDigits(n)=Reversed(ListOfDigits(n))); # Muniru A Asiru, Mar 08 2019
  • Haskell
    a002385 n = a002385_list !! (n-1)
    a002385_list = filter ((== 1) . a136522) a000040_list
    -- Reinhard Zumkeller, Apr 11 2011
    
  • Maple
    ff := proc(n) local i,j,k,s,aa,nn,bb,flag; s := n; aa := convert(s,string); nn := length(aa); bb := ``; for i from nn by -1 to 1 do bb := cat(bb,substring(aa,i..i)); od; flag := 0; for j from 1 to nn do if substring(aa,j..j)<>substring(bb,j..j) then flag := 1 fi; od; RETURN(flag); end; gg := proc(i) if ff(ithprime(i)) = 0 then RETURN(ithprime(i)) fi end;
    rev:=proc(n) local nn, nnn: nn:=convert(n,base,10): add(nn[nops(nn)+1-j]*10^(j-1),j=1..nops(nn)) end: a:=proc(n) if n=rev(n) and isprime(n)=true then n else fi end: seq(a(n),n=1..20000); # rev is a Maple program to revert a number - Emeric Deutsch, Mar 25 2007
    # A002385 Gets all base-10 palindromic primes with exactly d digits, in the list "Res"
    d:=7; # (say)
    if d=1 then Res:= [2,3,5,7]:
    elif d=2 then Res:= [11]:
    elif d::even then
        Res:=[]:
    else
        m:= (d-1)/2:
        Res2 := [seq(seq(n*10^(m+1)+y*10^m+digrev(n), y=0..9), n=10^(m-1)..10^m-1)]:
        Res:=[]: for x in Res2 do if isprime(x) then Res:=[op(Res),x]; fi: od:
    fi:
    Res; # N. J. A. Sloane, Oct 18 2015
  • Mathematica
    Select[ Prime[ Range[2100] ], IntegerDigits[#] == Reverse[ IntegerDigits[#] ] & ]
    lst = {}; e = 3; Do[p = n*10^(IntegerLength[n] - 1) + FromDigits@Rest@Reverse@IntegerDigits[n]; If[PrimeQ[p], AppendTo[lst, p]], {n, 10^e - 1}]; Insert[lst, 11, 5] (* Arkadiusz Wesolowski, May 04 2012 *)
    Join[{2,3,5,7,11},Flatten[Table[Select[Prime[Range[PrimePi[ 10^(2n)]+1, PrimePi[ 10^(2n+1)]]],# == IntegerReverse[#]&],{n,3}]]] (* The program uses the IntegerReverse function from Mathematica version 10 *) (* Harvey P. Dale, Apr 22 2016 *)
    genPal[n_Integer, base_Integer: 10] := Block[{id = IntegerDigits[n, base], insert = Join[{{}}, {# - 1} & /@ Range[base]]}, FromDigits[#, base] & /@ (Join[id, #, Reverse@id] & /@ insert)]; k = 1; lst = {2, 3, 5, 7}; While[k < 19, p = Select[genPal[k], PrimeQ];
    If[p != {}, AppendTo[lst, p]]; k++]; Flatten@ lst (* RGWv *)
    Select[ Prime[ Range[2100]], PalindromeQ] (* Jean-François Alcover, Feb 17 2018 *)
    NestList[NestWhile[NextPrime, #, ! PalindromeQ[#2] &, 2] &, 2, 41] (* Jan Mangaldan, Jul 01 2020 *)
  • PARI
    is(n)=n==eval(concat(Vecrev(Str(n))))&&isprime(n) \\ Charles R Greathouse IV, Nov 20 2012
    
  • PARI
    forprime(p=2,10^5, my(d=digits(p,10)); if(d==Vecrev(d),print1(p,", "))); \\ Joerg Arndt, Aug 17 2014
    
  • PARI
    A002385_row(n)=select(is_A002113, primes([10^(n-1),10^n])) \\ Terms with n digits. For larger n, better filter primes in palindromes. - M. F. Hasler, Dec 19 2024
    
  • Python
    from itertools import chain
    from sympy import isprime
    A002385 = sorted((n for n in chain((int(str(x)+str(x)[::-1]) for x in range(1,10**5)),(int(str(x)+str(x)[-2::-1]) for x in range(1,10**5))) if isprime(n))) # Chai Wah Wu, Aug 16 2014
    
  • Python
    from sympy import isprime
    A002385 = [*filter(isprime, (int(str(x) + str(x)[-2::-1]) for x in range(10**5)))]
    A002385.insert(4, 11)  # Yunhan Shi, Mar 03 2023
    
  • Python
    from sympy import isprime
    from itertools import count, islice, product
    def A002385gen(): # generator of palprimes
        yield from [2, 3, 5, 7, 11]
        for d in count(3, 2):
            for last in "1379":
                for p in product("0123456789", repeat=d//2-1):
                    left = "".join(p)
                    for mid in [[""], "0123456789"][d&1]:
                        t = int(last + left + mid + left[::-1] + last)
                        if isprime(t):
                            yield t
    print(list(islice(A002385gen(), 46))) # Michael S. Branicky, Apr 13 2025
    
  • Sage
    [n for n in (2..18181) if is_prime(n) and Word(n.digits()).is_palindrome()] # Peter Luschny, Sep 13 2018
    

Formula

Intersection of A000040 (primes) and A002113 (palindromes).
A010051(a(n)) * A136522(a(n)) = 1. [Reinhard Zumkeller, Apr 11 2011]
Complement of A032350 in A002113. - Jonathan Sondow, Jan 02 2018

Extensions

More terms from Larry Reeves (larryr(AT)acm.org), Oct 25 2000
Comment from A006093 moved here by Franklin T. Adams-Watters, Dec 03 2009

A006995 Binary palindromes: numbers whose binary expansion is palindromic.

Original entry on oeis.org

0, 1, 3, 5, 7, 9, 15, 17, 21, 27, 31, 33, 45, 51, 63, 65, 73, 85, 93, 99, 107, 119, 127, 129, 153, 165, 189, 195, 219, 231, 255, 257, 273, 297, 313, 325, 341, 365, 381, 387, 403, 427, 443, 455, 471, 495, 511, 513, 561, 585, 633, 645, 693, 717, 765, 771, 819, 843
Offset: 1

Views

Author

Keywords

Comments

If b > 1 is a binary palindrome then both (2^(m+1) + 1)*b and 2^(m+1) + 2^m - b are also, where m = floor(log_2(b)). - Hieronymus Fischer, Feb 18 2012
Floor and ceiling: If d > 0 is any natural number, then A206913(d) is the greatest binary palindrome <= d and A206914(d) is the least binary palindrome >= d. - Hieronymus Fischer, Feb 18 2012
The greatest binary palindrome <= the n-th non-binary-palindrome is that binary palindrome with number A154809(n)-n+1. The corresponding formula identity is: A206913(A154809(n)) = A006995(A154809(n)-n+1). - Hieronymus Fischer, Mar 18 2012
From Hieronymus Fischer, Jan 23 2013: (Start)
The number of binary digits of a(n) is A070939(a(n)) = 1 + floor(log_2(n)) + floor(log_2(n/3)), for n > 1.
Also: A070939(a(n)) = A070939(n) + A070939(floor(n/3)) - 1, for n <> 2. (End)
Rajasekaran, Shallit, & Smith show that this is an additive basis of order 4. - Charles R Greathouse IV, Nov 06 2018

Examples

			a(3) = 3, since 3 = 11_2 is the 3rd symmetric binary number;
a(6) = 9, since 9 = 1001_2 is the 6th symmetric binary number.
		

References

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

Crossrefs

See A057148 for the binary representations.
Cf. A178225, A005408, A164126, A154809 (complement).
Even numbers that are not the sum of two terms: A241491, A261678, A262556.
Cf. A145799.
Primes: A016041 and A117697.
Cf. A000051 (a subsequence).

Programs

  • Haskell
    a006995 n = a006995_list !! (n-1)
    a006995_list = 0 : filter ((== 1) . a178225) a005408_list
    -- Reinhard Zumkeller, Oct 21 2011
    
  • Magma
    [n: n in [0..850] | Intseq(n,2) eq Reverse(Intseq(n,2))];  // Bruno Berselli, Aug 29 2011
    
  • Maple
    dmax:= 15; # to get all terms with at most dmax binary digits
    revdigs:= proc(n)
      local L, Ln, i;
      L:= convert(n,base,2);
      Ln:= nops(L);
      add(L[i]*2^(Ln-i),i=1..Ln);
    end proc;
    A:= {0,1}:
    for d from 2 to dmax do
      if d::even then
        A:= A union {seq(2^(d/2)*x + revdigs(x),x=2^(d/2-1)..2^(d/2)-1)}
      else
        m:= (d-1)/2;
        B:={seq(2^(m+1)*x + revdigs(x),x=2^(m-1)..2^m-1)};
        A:= A union B union map(`+`,B,2^m)
      fi
    od:
    A;  # Robert Israel, Aug 17 2014
  • Mathematica
    palQ[n_Integer, base_Integer] := Module[{idn=IntegerDigits[n, base]}, idn==Reverse[idn]]; Select[Range[1000], palQ[ #, 2]&]
    Select[ Range[0, 1000], # == IntegerReverse[#, 2] &] (* Robert G. Wilson v, Feb 24 2018 *)
    Select[Range[0, 1000], PalindromeQ[IntegerDigits[#, 2]]&] (* Jean-François Alcover, Mar 01 2018 *)
  • PARI
    for(n=0,999,n-subst(Polrev(binary(n)),x,2)||print1(n,",")) \\ Thomas Buchholz, Aug 16 2014
    
  • PARI
    for(n=0,10^3, my(d=digits(n,2)); if(d==Vecrev(d), print1(n,", "))); \\ Joerg Arndt, Aug 17 2014
    
  • PARI
    is_A006995(n)=Vecrev(n=binary(n))==n \\ M. F. Hasler, Feb 23 2018
    
  • PARI
    A006995(n,m=logint(n,2),c=1<<(m-1),a,d)={if(n>=3*c,a=n-3*c;d=2*c^2,a=n-2*c;n%2*c+d=c^2)+sum(k=1,m-2^(n<3*c),if(bittest(a,m-1-k),1<>k))+(n>2)} \\ Based on Fischer's smalltalk program. - M. F. Hasler, Feb 23 2018
    
  • Python
    from itertools import count, islice, product
    def bin_pals(): # generator of binary palindromes in base 10
        yield from [0, 1]
        digits, midrange = 2, [[""], ["0", "1"]]
        for digits in count(2):
            for p in product("01", repeat=digits//2-1):
                left = "1"+"".join(p)
                for middle in midrange[digits%2]:
                    yield int(left + middle + left[::-1], 2)
    print(list(islice(bin_pals(), 58))) # Michael S. Branicky, Jan 09 2023
    
  • Python
    def A006995(n):
        if n == 1: return 0
        a = 1<<(l:=n.bit_length()-2)
        m = a|(n&a-1)
        return (m<Chai Wah Wu, Jun 10 2024
  • Sage
    def palgenbase2(): # generator of palindromes in base 2
        yield 0
        x, n, n2 = 1, 1, 2
        while True:
            for y in range(n,n2):
                s = format(y,'b')
                yield int(s+s[-2::-1],2)
            for y in range(n,n2):
                s = format(y,'b')
                yield int(s+s[::-1],2)
            x += 1
            n *= 2
            n2 *= 2 # Chai Wah Wu, Jan 07 2015
    
  • Sage
    [n for n in (0..843) if Word(n.digits(2)).is_palindrome()] # Peter Luschny, Sep 13 2018
    
  • Smalltalk
    A006995
    "Answer the n-th binary palindrome
    (nonrecursive implementation)"
    | m n a b c d k2 |
    n := self.
    n = 1 ifTrue: [^0].
    n = 2 ifTrue: [^1].
    m := n integerFloorLog: 2.
    c := 2 raisedToInteger: m - 1.
    n >= (3 * c)
      ifTrue:
       [a := n - (3 * c).
       d := 2 * c * c.
       b := d + 1.
       k2 := 1.
       1 to: m - 1
        do:
         [:k |
         k2 := 2 * k2.
         b := b + (a * k2 // c \\ 2 * (k2 + (d // k2)))]]
      ifFalse:
       [a := n - (2 * c).
       d := c * c.
       b := d + 1 + (n \\ 2 * c).
       k2 := 1.
       1 to: m - 2
        do:
         [:k |
         k2 := 2 * k2.
         b := b + (a * k2 // c \\ 2 * (k2 + (d // k2)))]].
    ^b // by Hieronymus Fischer, Feb 15 2013
    

Formula

A178225(a(n)) = 1; union of A048700 and A048701. - Reinhard Zumkeller, Oct 21 2011
From Hieronymus Fischer, Dec 31 2008, Jan 10 2012, Feb 18 2012: (Start)
Written as a decimal, a(10^n) has 2*n digits. For n > 1, the decimal expansion of a(10^n) starts with 22..., 23... or 24...:
a(1000) = 249903,
a(10^4) = 24183069,
a(10^5) = 2258634081,
a(10^6) = 249410097687,
a(10^7) = 24350854001805,
a(10^8) = 2229543293296319,
a(10^9) = 248640535848971067,
a(10^10)= 24502928886295666773.
Inequality: (2/9)*n^2 < a(n) < (1/4)*(n+1)^2, if n > 1.
lim sup_{n -> oo} a(n)/n^2 = 1/4, lim inf_{n -> oo} a(n)/n^2 = 2/9.
For n >= 2, a(2^n-1) = 2^(2n-2) - 1; a(2^n) = 2^(2n-2) + 1;
a(2^n+1) = 2^(2n-2) + 2^(n-1) + 1; a(2^n + 2^(n-1)) = 2^(2n-1) + 1.
Recursion for n > 2: a(n) = 2^(2k-q) + 1 + 2^p*a(m), where k = floor(log_2(n-1)), and p, q and m are determined as follows:
Case 1: If n = 2^(k+1), then p = 0, q = 0, m = 1;
Case 2: If 2^k < n < 2^k+2^(k-1), then p = k-floor(log_2(i))-1 with i = n-2^k, q = 2, m = 2^floor(log_2(i)) + i;
Case 3: If n = 2^k + 2^(k-1), then p = 0, q = 1, m = 1;
Case 4: If 2^k + 2^(k-1) < n < 2^(k+1), then p = k-floor(log_2(j))-1 with j = n-2^k-2^(k-1), q = 1, m = 2*2^floor(log_2(j))+j.
Non-recursive formula:
Let n >= 3, m = floor(log_2(n)), p = floor((3*2^(m-1)-1)/n), then
a(n) = 2^(2*m-1-p) + 1 + p*(1-(-1)^n)*2^(m-1-p) + sum_{k=1 .. m-1-p} (floor((n-(3-p)*2^(m-1))/2^(m-1-k)) mod 2)*(2^k+2^(2*m-1-p-k)). [Typo at the last exponent of the third sum term eliminated by the author, Sep 05 2018]
a(n) = 2^(2*m-2) + 1 + 2*floor((n-2^m)/2^(m-1)) + 2^(m-1)*floor((1/2)*min(n+1-2^m,2^(m-1)+1)) + 3*2^(m-1)*floor((1/2)*max(n+1-3*2^(m-1),0)) + 3*sum_{j=2 .. m-1} floor((n+2^(j-1)-2^m)/2^j)*2^(m-j). [Seems correct for n > 3. - The Editors]
Inversion formula: The index of any binary palindrome b = a(n) > 0 is n = palindromicIndex(b) = ((5-(-1)^m)/2 + Sum_{k=1..[m/2]} ([b/2^k] mod 2)/2^k)*2^[m/2], where [.] = floor(.) and m = [log_2(b)].
(End)
G.f.: g(x) = x^2 + 3x^3 + sum_{j=1..oo}( 3*2^j*(1-x^floor((j+1)/2))/(1-x)*x^((1/2)-floor((j+1)/2)) + f_j(x) - f_j(1/x))*x^(2*2^floor(j/2)+3*2^floor((j-1)/2)-(1/2)), where the f_j(x) are defined as follows:
f_1(x) = x^(1/2), and for j > 1,
f_j(x) = x^(1/2)*sum_{i=0..2^floor((j-1)/2)-1}((3+(1/2)*sum_{k=1..floor((j-1)/2)}(1-(-1)^floor(2i/2^k))*b(j,k))*x^i), where b(j,k) = 2^(floor((j-1)/2)-k)*((3+(-1)^j)*2^(2*k+1)+4) for k > 1, and b(j,1) = (2+(-1)^j)*2^(floor((j-1)/2)+1). - Hieronymus Fischer, Apr 04 2012
A044051(n) = (a(n)+1)/2 for n > 0. - Reinhard Zumkeller, Apr 20 2015
A145799(a(n)) = a(n). - Reinhard Zumkeller, Sep 24 2015
Sum_{n>=2} 1/a(n) = A244162. - Amiram Eldar, Oct 17 2020

Extensions

Edited and extended by Hieronymus Fischer, Feb 21 2012
Edited by M. F. Hasler, Feb 23 2018

A329419 Numbers all of whose divisors are binary palindromes.

Original entry on oeis.org

1, 3, 5, 7, 9, 15, 17, 21, 27, 31, 45, 51, 63, 73, 85, 93, 107, 119, 127, 153, 189, 219, 255, 257, 313, 365, 381, 443, 511, 765, 771, 1193, 1241, 1285, 1453, 1533, 1571, 1619, 1787, 1799, 1831, 1879, 2313, 3579, 3855, 4369, 4889, 5113, 5189, 5397, 5557, 5869
Offset: 1

Views

Author

Amiram Eldar, Nov 29 2019

Keywords

Comments

Subsequence of A163410, and differs from it from n = 65.

Examples

			15 is in the sequence since the binary representations of its divisors, 1, 3, 5, and 15, are all palindromes: 1, 11, 101, and 1111.
		

Crossrefs

Supersequence of A016041.

Programs

  • Mathematica
    binPalQ[n_] := PalindromeQ @ IntegerDigits[n, 2]; seqQ[n_] := binPalQ[n] && AllTrue[Most @ Divisors[n], binPalQ]; Select[Range[10^4], seqQ]

A117697 Palindromic primes in base 2 (written in base 2).

Original entry on oeis.org

11, 101, 111, 10001, 11111, 1001001, 1101011, 1111111, 100000001, 100111001, 110111011, 10010101001, 10110101101, 11000100011, 11001010011, 11011111011, 11100100111, 11101010111, 1001100011001, 1001111111001, 1010001000101
Offset: 1

Views

Author

Martin Renner, Apr 13 2006

Keywords

Crossrefs

Programs

  • Maple
    isA016041 := proc(n)
        local bin,dig ;
        if isprime(n) then
            bin := convert(n,base,2) ;
            for dig from 1 to nops(bin)/2 do
                if op(dig,bin) <> op(-dig,bin) then
                    return false;
                end if;
            end do ;
            return true;
        else
            false ;
        end if ;
    end proc:
    for i from 1 to 900 do p := ithprime(i) : if isA016041(p) then printf("%d, ",A007088(p)) ; fi ; od : # R. J. Mathar, Feb 25 2007
  • Mathematica
    pal2Q[n_] := Reverse[x = IntegerDigits[n, 2]] == x; BaseForm[Select[Prime[Range[700]], pal2Q[#] &], 2] (* Jayanta Basu, Jun 24 2013 *)
    FromDigits /@ Select[IntegerDigits[Prime@ Range[1000], 2], PalindromeQ] (* Michael De Vlieger, Oct 28 2020 *)

Formula

a(n) = A007088(A016041(n)). - R. J. Mathar, Feb 25 2007

A095749 Square array A(row>=1, col>=1) by antidiagonals: A(r,c) contains the c:th prime p for which A037888(p)=(r-1).

Original entry on oeis.org

3, 5, 2, 7, 11, 43, 17, 13, 53, 151, 31, 19, 71, 179, 599, 73, 23, 79, 233, 683, 2111, 107, 29, 83, 241, 739, 2143, 8543, 127, 37, 101, 271, 797, 2503, 9103, 33023, 257, 41, 109, 311, 853, 2731, 9623, 33151, 131839, 313, 47, 113, 331, 937, 3011, 10427, 33599, 135647, 531071
Offset: 1

Views

Author

Antti Karttunen, Jun 12 2004

Keywords

Examples

			a(1) = A(1,1) = 3 (11 in binary) as it is the first prime whose binary expansion is palindromic. a(2) = A(1,2) = 5 (101 in binary) as it is the second prime whose binexp is palindromic. a(3) = A(2,1) = 2 (10 in binary) as it is the first prime whose binexp needs a flip of just one bit to become palindrome. a(4) = A(1,3) = 7 (111 in binary) as it is the third prime whose binexp is palindromic. a(5) = A(2,2) = 11 (1011 in binary) as it is the second prime whose binexp needs a flip of just one bit to become palindrome.
		

Crossrefs

Row 1: A016041, 2: A095743, 3: A095744, 4: A095745, 5: A095746. Cf. also A095759. A095747-A095748. Permutation of primes (A000040).

A117772 Total number of palindromic primes in base 2 below 2^n.

Original entry on oeis.org

0, 1, 3, 3, 5, 5, 8, 8, 11, 11, 18, 18, 30, 30, 53, 53, 93, 93, 187, 187, 329, 329, 600, 600, 1080, 1080, 1936, 1936, 3657, 3657, 6756, 6756, 12328, 12328, 23127, 23127, 43909, 43909, 83377, 83377, 156049, 156049, 295916, 295916, 570396, 570396, 1090772
Offset: 1

Views

Author

Martin Renner, Apr 15 2006

Keywords

Comments

Every palindrome with an even number of digits is divisible by 11 (in base 2) and therefore is composite (not prime). Hence there is only one palindromic prime with an even number of digits, namely 11_2 = 3_{10}.

Crossrefs

Extensions

a(23)-a(40) from Donovan Johnson, Dec 02 2009
Extended to a(66) by Martin Raab, Oct 20 2015

A256081 Non-palindromic balanced primes in base 2.

Original entry on oeis.org

397, 1427, 1459, 1483, 1613, 1693, 4657, 4721, 4931, 5077, 5273, 5581, 5651, 5749, 6043, 6329, 6637, 6701, 6791, 7127, 7211, 7547, 10069, 10937, 10979, 12011, 12757, 13597, 13789, 18121, 18217, 18307, 18947, 19013, 19141, 19237, 19267, 19813, 19861
Offset: 1

Views

Author

M. F. Hasler, Mar 14 2015

Keywords

Comments

Here a number is called balanced if the sum of digits weighted by their arithmetic distance from the "center" is zero. Obviously, all palindromic numbers are balanced; cf. A016041 for base-2 palindromic primes.
These are the primes in A256082. This is the binary variant of the decimal version A256076 suggested by Eric Angelini.

Crossrefs

Programs

  • Maple
    filter:= proc(n) local L, m;
      L:= convert(n, base, 2);
      m:= (1+nops(L))/2;
      add(L[i]*(i-m), i=1..nops(L))=0 and isprime(n) and L <> ListTools:-Reverse(L)
    end proc: select(filter, [seq(i,i=3..20000,2)]);# Robert Israel, May 29 2018
  • PARI
    is(n,b=2,d=digits(n,b),o=(#d+1)/2)=!(vector(#d,i,i-o)*d~)&&d!=Vecrev(d)&&isprime(n)
Showing 1-10 of 34 results. Next