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

A164125 First differences of A029971.

Original entry on oeis.org

11, 10, 128, 22, 60, 524, 180, 156, 156, 180, 58, 180, 66, 90, 90, 66, 90, 6320, 714, 1008, 2190, 2650, 1722, 198, 1722, 41510, 810, 594, 1620, 6570, 3546, 5736, 1620, 1404, 810, 594, 1620, 522, 4428, 810, 1332, 1620, 1404, 7356, 594, 810, 3546, 2214
Offset: 1

Views

Author

Keywords

Comments

Differences between primes that are palindromic in base 3.

Examples

			a(4) = 22 = A029971(5)-A029971(4).
		

Crossrefs

Programs

  • Mathematica
    f[n_]:=FromDigits[RealDigits[n,3][[1]]]==FromDigits[Reverse[RealDigits[n, 3][[1]]]]; a=2;lst={};Do[p=Prime[n];If[f[p],AppendTo[lst,p-a];a=p], {n,1,8!,1}];lst

Extensions

Definition simplified, initial 0 removed by R. J. Mathar, Nov 17 2009

A016041 Primes that are palindromic in base 2 (but written here in base 10).

Original entry on oeis.org

3, 5, 7, 17, 31, 73, 107, 127, 257, 313, 443, 1193, 1453, 1571, 1619, 1787, 1831, 1879, 4889, 5113, 5189, 5557, 5869, 5981, 6211, 6827, 7607, 7759, 7919, 8191, 17377, 18097, 18289, 19433, 19609, 19801, 21157, 22541, 22669, 22861, 23581, 24029
Offset: 1

Views

Author

Keywords

Comments

See A002385 for palindromic primes in base 10, and A256081 for primes whose binary expansion is "balanced" (see there) but not palindromic. - M. F. Hasler, Mar 14 2015
Number of terms less than 4^k, k=1,2,3,...: 1, 3, 5, 8, 11, 18, 30, 53, 93, 187, 329, 600, 1080, 1936, 3657, 6756, 12328, 23127, 43909, 83377, 156049, 295916, 570396, 1090772, 2077090, 3991187, 7717804, 14825247, 28507572, 54938369, 106350934, ..., partial sums of A095741 plus 1. - Robert G. Wilson v, Feb 23 2018, corrected by Jeppe Stig Nielsen, Jun 17 2023

Crossrefs

Intersection of A000040 and A006995.
First row of A095749.
A095741 gives the number of terms in range [2^(2n), 2^(2n+1)].
Cf. A095730 (primes whose Zeckendorf expansion is palindromic), A029971 (primes whose ternary (base-3) expansion is palindromic).
Cf. A117697 (written in base 2), A002385, A194097, A256081.

Programs

  • Magma
    [NthPrime(n): n in [1..5000] | (Intseq(NthPrime(n), 2) eq Reverse(Intseq(NthPrime(n), 2)))]; // Vincenzo Librandi, Feb 24 2018
    
  • Mathematica
    lst = {}; Do[ If[ PrimeQ@n, t = IntegerDigits[n, 2]; If[ FromDigits@t == FromDigits@ Reverse@ t, AppendTo[lst, n]]], {n, 3, 50000, 2}]; lst (* syntax corrected by Robert G. Wilson v, Aug 10 2009 *)
    pal2Q[n_] := Reverse[x = IntegerDigits[n, 2]] == x; Select[Prime[Range[2800]], pal2Q[#] &] (* Jayanta Basu, Jun 23 2013 *)
    genPal[n_Integer, base_Integer: 10] := Block[{id = IntegerDigits[n, base], insert = Join[{{}}, {# - 1} & /@ Range[base]]}, FromDigits[#, base] & /@ (Join[id, #, Reverse@id] & /@ insert)]; k = 0; lst = {}; While[k < 100, AppendTo[lst, Select[ genPal[k, 2], PrimeQ]]; lst = Flatten@ lst; k++]; lst (* Robert G. Wilson v, Feb 23 2018 *)
  • PARI
    is(n)=isprime(n)&&Vecrev(n=binary(n))==n \\ M. F. Hasler, Feb 23 2018
    
  • Python
    from sympy import isprime
    def ok(n): return isprime(n) and (b:=bin(n)[2:]) == b[::-1]
    print([k for k in range(10**5) if ok(k)]) # Michael S. Branicky, Apr 20 2024

Formula

Sum_{n>=1} 1/a(n) = A194097. - Amiram Eldar, Mar 19 2021

Extensions

More terms from Patrick De Geest

A117698 Palindromic primes in base 3 (written in base 3).

Original entry on oeis.org

2, 111, 212, 12121, 20102, 22122, 1001001, 1021201, 1111111, 1201021, 1221221, 2001002, 2021202, 2101012, 2111112, 2121212, 2201022, 2211122, 102111201, 110111011
Offset: 1

Views

Author

Martin Renner, Apr 13 2006

Keywords

Crossrefs

Cf. A029971.

A117775 Total number of palindromic primes in base 3 below 3^n.

Original entry on oeis.org

1, 1, 3, 3, 6, 6, 18, 18, 26, 26, 73, 73, 179, 179, 459, 459, 1179, 1179, 3004, 3004, 8111, 8111, 22183, 22183, 60789, 60789, 168641, 168641, 469689, 469689, 1322664, 1322664, 3691761, 3691761, 10390938, 10390938, 29502559, 29502559, 84012658, 84012658, 239417332, 239417332
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 3) and therefore is composite (not prime). Hence there is no palindromic prime with an even number of digits.

Examples

			a(5) = a(6) = 6 as the six palindromic primes below 3^5 are 2_10 = 2_3, 13_10 = 111_3, 23_10 = 212_3, 151_10 = 12121_3, 173_10 = 20102_3, 233_10 = 22122_3. There are no palindromic primes with 6 digits so a(5) = a(6). - _David A. Corneth_, Mar 21 2021
		

Crossrefs

Formula

a(2*k-1) = a(2*k) for k >= 1. - Bernard Schott, Mar 23 2021

Extensions

a(15)-a(42) from the data at A117776 added by Amiram Eldar, Mar 21 2021

A164126 First differences of A006995.

Original entry on oeis.org

1, 2, 2, 2, 2, 6, 2, 4, 6, 4, 2, 12, 6, 12, 2, 8, 12, 8, 6, 8, 12, 8, 2, 24, 12, 24, 6, 24, 12, 24, 2, 16, 24, 16, 12, 16, 24, 16, 6, 16, 24, 16, 12, 16, 24, 16, 2, 48, 24, 48, 12, 48, 24, 48, 6, 48, 24, 48, 12, 48, 24, 48, 2, 32, 48, 32, 24, 32, 48, 32, 12, 32, 48, 32, 24, 32, 48, 32, 6
Offset: 1

Views

Author

Keywords

Comments

Contribution from Hieronymus Fischer, Feb 18 2012: (Start)
From the formula section it follows that a(2^m - 1 + 2^(m-1) - k) = a(2^m - 1 + k) for 0 <= k <= 2^(m-1), as well as a(2^m - 1 + 2^(m-1) - k) = 2 for k=0, 2^(m-1) and a(2^m - 1 + 2^(m-1) - k) = 6 for k=2^(m-2), hence, starting from positions n=2^m-1, the following 2^(m-1) terms form symmetric tuples limited on the left and on the right by a '2' and always having a '6' as the center element.
Example: for n = 15 = 2^4 - 1, we have the (2^3+1)-tuple (2,8,12,8,6,8,12,8,2).
Further on, since a(2^m - 1 + 2^(m-1) + k) = a(2^(m+1) - 1 - k) for 0 <= k <= 2^(m-1) an analogous statement holds true for starting positions n = 2^m + 2^(m-1) - 1.
Example: for n = 23 = 2^4 + 2^3 - 1, we find the (2^3+1)-tuple (2,24,12,24,6,24,12,24,2).
If we group the sequence terms according to the value of m=floor(log_2(n)), writing those terms together in separate lines and opening each new line for n >= 2^m + 2^(m-1), then a kind of a 'logarithmic shaped' cone end will be formed, where both the symmetry and the calculation rules become obvious. The first 63 terms are depicted below:
1
2
2
2 2
6 2
4 6 4 2
12 6 12 2
8 12 8 6 8 12 8 2
24 12 24 6 24 12 24 2
16 24 16 12 16 24 16 6 16 24 16 12 16 24 16 2
48 24 48 12 48 24 48 6 48 24 48 12 48 24 48 2
.
(End)
Decremented by 1, also the sequence of run lengths of 0's in A178225. - Hieronymus Fischer, Feb 19 2012

Examples

			a(1) = A006995(2) - A006995(1) = 1 - 0 = 1.
		

Crossrefs

Programs

  • Mathematica
    f[n_]:=FromDigits[RealDigits[n,2][[1]]]==FromDigits[Reverse[RealDigits[n, 2][[1]]]]; a=1;lst={};Do[If[f[n],AppendTo[lst,n-a];a=n],{n,1,8!,1}]; lst
  • Python
    def A164126(n):
        if n == 1: return 1
        m = (a:=1<<(l:=n.bit_length()-2))|(n&a-1)
        k = (m<Chai Wah Wu, Jun 11 2024

Formula

a(n) = A006995(n+1) - A006995(n).
Contribution from Hieronymus Fischer, Feb 17 2012: (Start)
a(4*2^m - 1) = a(6*2^m - 1) = 2;
a(5*2^m - 1) = a(7*2^m - 1) = 6 (for m > 0);
Let m = floor(log_2(n)), then
Case 1: a(n) = 2, if n+1 = 2^(m+1) or n+1 = 3*2^(m-1);
Case 2: a(n) = 2^(m-1), if n = 0(mod 2) and n < 3*2^(m-1);
Case 3: a(n) = 3*2^(m-1), if n = 0(mod 2) and n >= 3*2^(m-1);
Case 4: a(n) = 3*2^(m-1)/gcd(n+1-2^m, 2^m), otherwise.
Cases 2-4 above can be combined as
Case 2': a(n) = (2 - (-1)^(n-(n-1)*floor(2*n/(3*2^m))))*2^(m-1)/gcd(n+1-2^m, 2^m).
Recursion formula:
Let m = floor(log_2(n)); then
Case 1: a(n) = 2*a(n-2^(m-1)), if 2^m <= n < 2^m + 2^(m-2) - 1;
Case 2: a(n) = 6, if n = 2^m + 2^(m-2) - 1;
Case 3: a(n) = a(n-2^(m-2)), if 2^m + 2^(m-2) <= n < 2^m + 2^(m-1) - 1;
Case 4: a(n) = 2, if n = 2^m + 2^(m-1) - 1;
Case 5: a(n) = (2 + (-1)^n)*a(n-2^(m-1)), otherwise (which means 2^m + 2^(m-1) <= n < 2^(m+1)).
(End)

Extensions

a(1) changed to 1 and keyword:base added by R. J. Mathar, Aug 26 2009

A333421 Primes that are palindromic in factorial base.

Original entry on oeis.org

3, 7, 11, 41, 127, 139, 173, 179, 191, 751, 811, 5113, 5167, 5419, 5443, 6581, 6659, 6737, 6761, 6833, 6863, 6911, 6959, 40609, 40897, 41047, 41479, 42061, 42349, 42499, 42643, 42787, 50549, 51131, 51419, 51563, 52289, 52433, 52583, 52727, 363361, 363481, 365473
Offset: 1

Views

Author

Amiram Eldar, Mar 20 2020

Keywords

Examples

			3 is a term since it is a prime number and its factorial base representation is 11 which is a palindrome.
		

Crossrefs

Programs

  • Mathematica
    max = 9; Select[Range[0, max! - 1], PrimeQ[#] && PalindromeQ @ IntegerDigits[#, MixedRadix[Range[max, 2, -1]]] &]

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

A230820 Table, read by antidiagonals, of palindromic primes in base b expressed in decimal.

Original entry on oeis.org

3, 2, 5, 2, 13, 7, 2, 3, 23, 17, 2, 3, 5, 151, 31, 2, 3, 31, 17, 173, 73, 2, 3, 5, 41, 29, 233, 107, 2, 3, 5, 7, 67, 59, 757, 127, 2, 3, 5, 71, 37, 83, 257, 937, 257, 2, 3, 5, 7, 107, 43, 109, 373, 1093, 313, 2, 3, 5, 7, 73, 157, 61, 701, 409, 1249, 443
Offset: 1

Views

Author

Robert G. Wilson v, Oct 30 2013

Keywords

Examples

			\r
b\
.2.3...5...7...17...31...73..107..127...257...313...443..1193..1453..1571.=A016041
.3.2..13..23..151..173..233..757..937..1093..1249..1429..1487..1667..1733.=A029971
.4.2...3...5...17...29...59..257..373...409...461...509...787...839...887.=A029972
.5.2...3..31...41...67...83..109..701...911..1091..1171..1277..1327..1667.=A029973
.6.2...3...5....7...37...43...61...67...191...197..1297..1627..1663..1699.=A029974
.7.2...3...5...71..107..157..257..271...307..2549..2647..2801..3347..3697.=A029975
.8.2...3...5....7...73...89...97..113...211...227...251...349...373...463.=A029976
.9.2...3...5....7..109..127..173..191...227...337...373...419...601...619.=A029977
10.2...3...5....7...11..101..131..151...181...191...313...353...373...383.=A002385
11.2...3...5....7..199..277..421..443...499...521...587...643...709...743.=A029978
12.2...3...5....7...11...13..157..181...193...229...241...277...761...773.=A029979
...
inf..2..3..5..7..11..13..17..19..23..29..31..37..41..43..47..53..59..61...=A000040
		

Crossrefs

Programs

  • Maple
    A230820 := proc(b,n)
        option remember;
        local a,dgs ;
        if n = 1 then
            if b = 2 then
                return 3;
            else
                return 2;
            end if;
        else
            for a from procname(b,n-1)+1 do
                if isprime(a) then
                    ispal := true ;
                    dgs := convert(a,base,b) ;
                    for i from 1 to nops(dgs)/2 do
                        if op(i,dgs) <> op(-i,dgs) then
                            ispal := false;
                        end if;
                    end do:
                    if ispal then
                        return a;
                    end if;
                end if;
            end do:
        end if;
    end proc:
    for b from 2 to 9 do
        for n from 1 to 9 do
            printf("%3d ",A230820(b,n)) ;
        end do:
        printf("\n") ;
    end do; # R. J. Mathar, Feb 16 2014
  • Mathematica
    palQ[n_Integer, base_Integer] := Module[{idn = IntegerDigits[ n, base]}, idn == Reverse@ idn]; Table[Select[Prime@Range@500, palQ[#, k + 1] &][[b - k + 1]], {b, 11}, {k, b, 1, -1}] // Flatten

A333424 Primes that are palindromes in primorial base.

Original entry on oeis.org

3, 7, 11, 31, 47, 211, 223, 229, 281, 293, 2311, 2347, 2383, 2843, 2879, 30091, 30181, 30211, 30307, 30367, 30427, 30493, 30553, 30643, 30829, 30859, 34871, 34961, 35051, 35117, 35267, 35363, 35393, 35423, 510751, 511711, 513067, 513307, 515143, 517459, 518179
Offset: 1

Views

Author

Amiram Eldar, Mar 20 2020

Keywords

Examples

			3 is a term since it is a prime number and its representation in primorial base is 11 (1 * 2# + 1) which is a palindrome.
		

Crossrefs

Programs

  • Mathematica
    max = 8; bases = Prime @ Range[max, 1, -1]; nmax = Times @@ bases - 1; Select[Range[nmax], PrimeQ[#] && PalindromeQ @ IntegerDigits[#, MixedRadix[bases]] &]

A117776 Total number of palindromic primes in base 3 with n digits.

Original entry on oeis.org

1, 0, 2, 0, 3, 0, 12, 0, 8, 0, 47, 0, 106, 0, 280, 0, 720, 0, 1825, 0, 5107, 0, 14072, 0, 38606, 0, 107852, 0, 301048, 0, 852975, 0, 2369097, 0, 6699177, 0, 19111621, 0, 54510099, 0, 155404674, 0
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 3) and therefore is composite (not prime). Hence there is no palindromic prime with an even number of digits.

Crossrefs

Extensions

a(15)-a(42) from Chai Wah Wu, Dec 27 2015
Showing 1-10 of 11 results. Next