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

A127746 Smallest n-digit prime whose reversal is also prime.

Original entry on oeis.org

2, 13, 107, 1009, 10007, 100049, 1000033, 10000169, 100000007, 1000000007, 10000000207, 100000000237, 1000000000091, 10000000000313, 100000000000261, 1000000000000273, 10000000000000079, 100000000000000049
Offset: 1

Views

Author

Lekraj Beedassy, Jan 28 2007

Keywords

Comments

Smallest n-digit emirp (A006567).
Largest n-digit emirp is given by A114019.
Least emirp (A006567) greater than 10^(n-1). [Jonathan Vos Post, Nov 15 2009]
Palindromes not permitted (with the exception of the first term), so for example 101 is not a term. - Harvey P. Dale, Mar 11 2017

Crossrefs

Programs

  • Mathematica
    f[n_] := Block[{k = 10^(n - 1), id, rid}, While[ id = IntegerDigits[k]; rid = Reverse[id]; ! PrimeQ[k] || ! PrimeQ[FromDigits[rid]] || id == rid, k++ ]; k]; Table[f[n], {n, 2, 19}] (* Ray Chandler, Jan 30 2007 *)
    sndp[n_]:=Module[{np=NextPrime[10^(n+1)]},While[PalindromeQ[np] || !PrimeQ[ IntegerReverse[ np]],np= NextPrime[np]];np]; Join[{2},Array[sndp,20,0]] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Mar 11 2017 *)

Extensions

Edited and extended by Ray Chandler, Jan 30 2007

A127747 Smallest n-digit emirp (A006567) with strictly increasing (distinct) digits.

Original entry on oeis.org

13, 149, 1237, 12689, 345689, 1235789
Offset: 2

Views

Author

Lekraj Beedassy, Jan 28 2007

Keywords

Crossrefs

Extensions

Edited and extended by Ray Chandler, Jan 30 2007

A127827 Smallest n-digit emirp (A006567) with nondecreasing digits.

Original entry on oeis.org

13, 113, 1223, 11149, 111119, 1111339, 11111117, 111111199, 1111111999, 11111111113, 111111111149, 1111111111267, 11111111111257, 111111111113447, 1111111111112227, 11111111111122223, 111111111111113569, 1111111111111113779, 11111111111111133677, 111111111111111111157, 1111111111111111122359, 11111111111111111133469
Offset: 2

Views

Author

Ray Chandler, Jan 31 2007

Keywords

Crossrefs

Programs

  • Maple
    nextl:= proc(L)
    local m,k,r;
    # L a list of digits 1-9, last odd, in nondecreasing order
    if L[-1]<= 7 then return subsop(-1=L[-1]+2, L) fi;
    m:= nops(L); k:= m-1;
    while L[k] =9 do k:= k-1 od:
    r:= [op(L[1..k-1]),(L[k]+1) $ (m+1-k)];
    if r[-1]::even then r:= subsop(-1=r[-1]+1, r) fi;
    r
    end proc:
    f:= proc(n) local L,p,q,i;
      L:= [1$n];
      do
        p:= add(L[i]*10^(i-1),i=1..n);
        q:= add(L[-i]*10^(i-1),i=1..n);
        if q <> p and isprime(p) and isprime(q) then return(q) fi;
        L:= nextl(L);
      od
    end proc:
    map(f, [$2..30]); # Robert Israel, Nov 19 2017
  • Python
    from sympy import isprime
    from itertools import count, islice, combinations_with_replacement as mc
    def bgen(d):
        nd = ("".join(m) for m in mc("123456789", d))
        yield from filter(isprime, map(int, nd))
    def ok(ndp):
        s = str(ndp)
        return len(set(s)) != 1 and isprime(int(s[::-1]))
    def agen():
        yield from (next(filter(ok, bgen(d))) for d in count(2))
    print(list(islice(agen(), 22))) # Michael S. Branicky, Jun 26 2022

Extensions

More terms from Robert Israel, Nov 19 2017

A167992 Least n-digit emirp (A006567) with emirp digital sum, or 0 if no such value.

Original entry on oeis.org

0, 0, 157, 1097, 10039, 100129, 1000039, 10000169, 100000543, 1000000097, 10000000277, 100000000237, 1000000001159, 10000000000853, 100000000001173, 1000000000000273, 10000000000000079, 100000000000001249
Offset: 1

Views

Author

Jonathan Vos Post, Nov 16 2009

Keywords

Comments

Least emirp (non-palindromic prime in A007500, i.e., prime whose reversal is a different prime) greater than 10^n, for which the sum of digits (A007953) is also an emirp.

Examples

			a(1) = a(2) = 0. a(3) = 157 because 157 is the least non-palindromic prime p > 10^3 such that R(p), in this case 751, is also prime, and the sum of digits sod(p), in this case 1+5+7 = 13, is likewise an emirp (prime with reversal a different prime). a(4) = 1097 because it is the smallest 4-digit prime, whose reversal (7901) is a different prime, and whose digital sum 1+0+9+7 = 17, which is prime and has a prime reversal (71).
		

Crossrefs

Programs

  • Maple
    read("transforms") ; A007953 := proc(n) local d ; add(d, d=convert(n,base,10)) ; end proc: isA006567 := proc(p) if isprime(p) then isprime(digrev(p)) and digrev(p) <> p ; else false ; end if; end proc ; A167992 := proc(n) local p; p := nextprime(10^(n-1)) ; while p <= 10^n do if isA006567(p) and isA006567(A007953(p)) then return p; end if; p := nextprime(p) ; end do ; return 0 ; end proc: seq(A167992(n),n=1..70) ; # R. J. Mathar, Nov 18 2009

Formula

a(n) = Min{p > 10^n in A006567, and A007953(p) is in A006567} = Min{p > 10^n in A000040 such that A004086(p) is in A000040, and A004086(p) distinct from p, and in A006567(p) is in A000040, and A004086(p) distinct from A006567(p), and in A000040}.

Extensions

More terms from R. J. Mathar, Nov 18 2009

A168159 Distance of the least reversible n-digit prime from 10^(n-1).

Original entry on oeis.org

1, 1, 1, 9, 7, 49, 33, 169, 7, 7, 207, 237, 91, 313, 261, 273, 79, 49, 2901, 51, 441, 193, 9, 531, 289, 1141, 67, 909, 331, 753, 2613, 657, 49, 4459, 603, 1531, 849, 2049, 259, 649, 2119, 1483, 63, 6747, 519, 3133, 937, 1159, 1999, 6921, 2949, 613, 4137, 1977, 31
Offset: 1

Views

Author

M. F. Hasler, Nov 21 2009

Keywords

Comments

A (much) more compact form of A114018 (cf. formula). Since this sequence and A114018 refer to "reversible primes" (A007500), while A122490 seems to use "emirps" (A006567), a(n+1) differs from A122490(n) iff 10^n+1 is prime <=> a(n+1)=1 <=> A114018(n)=10^n+1.

Programs

  • Mathematica
    Table[p = NextPrime[y = 10^(n - 1)]; While[! PrimeQ[FromDigits[Reverse[IntegerDigits[p]]]], p = NextPrime[p]]; p - y, {n, 55}] (* Jayanta Basu, Aug 09 2013 *)
  • PARI
    for(x=1,1e99, until( isprime(x=nextprime(x+1)) & isprime(eval(concat(vecextract(Vec(Str(x)),"-1..1")))),);print1(x-10^ (#Str(x)-1),", "); x=10^#Str(x)-1)
    
  • Python
    from sympy import isprime
    def c(n): return isprime(n) and isprime(int(str(n)[::-1]))
    def a(n): return next(p-10**(n-1) for p in range(10**(n-1), 10**n) if c(p))
    print([a(n) for n in range(1, 56)]) # Michael S. Branicky, Jun 27 2022

Formula

a(n)=A114018(n)-10^(n-1)

A168174 Emirps (A006567) with emirp number of digits and emirp digital sum.

Original entry on oeis.org

1000000001159, 1000000002217, 1000000003463, 1000000004161, 1000000005713, 1000000005911, 1000000006037, 1000000006451, 1000000006699, 1000000007333, 1000000009403, 1000000010249, 1000000010447, 1000000010483, 1000000011019
Offset: 1

Views

Author

Jonathan Vos Post, Nov 19 2009

Keywords

Comments

Last 13-digit examples: 9999999990583, 9999999990853, 9999999995191, 9999999996901, 9999999997919, 9999999998987. First examples of some digit lengths: 10^16 + {79, 1551, 3711, 7711, 9421, 9867}; 10^30 + {2613, 29979, 37857, 41461, 47577}; 10^36 + {9061, 21081, 52351, 71017, 95781}; 10^70 + {691, 19321, 203403, 225201, 231987}; 10^72 + {97167, 158637, 227001, 233679, 265021}. ... and skipping a few other legal lengths... 10^148 + 53967 -- Jack Brennen

Examples

			a(1) = 1000000001159, which is prime, and R(1000000001159) = 951100000000 is prime, and sod(1000000001159) = 17 is prime, and R(17) = 71 is prime.
		

Crossrefs

Formula

{p: p in A006567 and A055642(p) in A006567 and A007953(p) in A006567}.

A227864 Smallest base in which n's digital reversal is prime, or 0 if no such base exists.

Original entry on oeis.org

0, 0, 3, 2, 0, 2, 2, 2, 4, 6, 2, 2, 2, 2, 2, 3, 8, 2, 3, 3, 2, 3, 2, 2, 2, 2, 2, 9, 2, 2, 6, 2, 4, 3, 2, 3, 12, 2, 6, 3, 2, 2, 6, 2, 2, 3, 2, 2, 2, 3, 2, 9, 2, 2, 3, 2, 2, 3, 2, 4, 12, 2, 2, 3, 12, 3, 6, 2, 2, 3, 10, 2, 6, 2, 2, 3, 10, 2, 26, 3, 2, 27, 2, 2
Offset: 0

Views

Author

Carl R. White, Nov 01 2013

Keywords

Comments

0 and 1 are not prime and are single digits in all bases, so no reversal of digits can make them prime. a(n) is therefore 0 for both.
4 is not prime and so cannot be prime if reversed in any base where it is a single digit. This leaves bases 2 and 3 where, upon reversal, it is 1 and 4 respectively. Neither are prime, and so a(4) is also 0.
Conjecture 1: 0, 1 and 4 are the only values where there is no base in which a digital reversal makes a prime.
It is clear that for any prime p, a(p) cannot be zero, since a(p)=p+1 is a solution if there is none smaller.
Conjecture 2: n = 2 is the only prime p which must be represented in base p+1, i.e., trivially, as a single digit, in order for its reversal to be prime.
Corollary: Since a(n) cannot be n itself -- reversing n in base n obtains 1, which is not prime -- this would mean that for all positive n except 2, a(n) < n.
Other than its small magnitude, a(n) = 2 occurs often due to the fact that a reversed positive binary number is guaranteed to be odd and thus stands a greater chance of being prime.
Similarly, many solutions exist solely because reversal removes all powers of the base from n, reducing the number of divisors. Thus based solely on observation:
Conjecture 3: With the restriction gcd(base,n) = 1, a(n) = 0 except for n = 2, 3 and 6k+-1, for positive integer k, i.e., terms of A038179.

Examples

			9 in base 2 is 1001, which when reversed is the same and so not prime. In base 3 it is 100, which becomes 1 when reversed and also not prime. Base 4: 21 -> 12 (6 decimal), not prime; Base 5: 14 -> 41 (21 decimal), not prime; Base 6: 13 -> 31 (19 decimal), which is prime, so a(9) = 6, i.e., 6 is the smallest base in which 9's digital reversal is a prime number.
		

Crossrefs

Positions of 2's: A204232.

Programs

  • Python
    from sympy import isprime
    from sympy.ntheory.digits import digits
    def okb(n, b):
        return isprime(sum(d*b**i for i, d in enumerate(digits(n, b)[1:])))
    def a(n):
        for b in range(2, n+2):
            if okb(n, b): return b
        return 0
    print([a(n) for n in range(84)]) # Michael S. Branicky, Sep 06 2021

A374350 Least n-digit reversible prime whose difference from its reversal is minimal.

Original entry on oeis.org

2, 11, 101, 1231, 10301, 105601, 1003001, 10012001, 100030001, 1007457001, 10000500001, 100124521001, 1000008000001, 10000523500001, 100000323000001, 1000034344300001, 10000000500000001, 100000188981000001, 1000000008000000001, 10000001189110000001, 100000000212000000001
Offset: 1

Views

Author

Robert G. Wilson v, Jul 05 2024

Keywords

Comments

Inspired by A084475 and A373349.
For n > 1, a(2n) has a difference of 9*10^n and a(2n-1) has a difference of 0.

Examples

			a(3) = 101 since its reversal is also 101;
a(4) = 1231 since its reversal is 1321 which is also prime and their difference is minimal at 90;
a(6) = 105601 since its reversal is 106501 which is also prime and their difference is minimal at 900;
a(8) = 10012001 since its reversal is 10021001 which is also prime and their difference is minimal at 9000; etc.
		

Crossrefs

Programs

  • Mathematica
    fe[n_] := Block[{k = 1, j, p, q}, While[ j = k(10^IntegerLength[k]) + IntegerReverse[k +1]; p = 10^(2 n -1) + j(10^(n - IntegerLength[j]/2)) + 1; q = IntegerReverse@ p; !PrimeQ@ p || !PrimeQ@ q, k++; If[ Mod[k, 10] == 9, k++]]; p]; fe[1] = 11;
    fo[n_] := Block[{k = 0, j, p}, While[ j = k(10^(IntegerLength[k] -1)) + IntegerReverse@ Quotient[k, 10]; p = 10^(2n -2) + j(10^(n - (IntegerLength[j] + 1)/2)) +1; !PrimeQ@ p, k++]; p];
    a[n_] := If[ OddQ@ n, fo[(n +1)/2], fe[n/2]]; Array[a, 21]

Formula

a(2n-1) = A100027(n) = A028989(n).
Showing 1-8 of 8 results.