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

A095179 Numbers whose reversed digit representation is prime.

Original entry on oeis.org

2, 3, 5, 7, 11, 13, 14, 16, 17, 20, 30, 31, 32, 34, 35, 37, 38, 50, 70, 71, 73, 74, 76, 79, 91, 92, 95, 97, 98, 101, 104, 106, 107, 110, 112, 113, 118, 119, 124, 125, 128, 130, 131, 133, 134, 136, 140, 142, 145, 146, 149, 151, 152, 157, 160, 164, 166, 167, 170, 172
Offset: 1

Views

Author

Cino Hilliard, Jun 21 2004

Keywords

Comments

If m is a term, then 10*m is another term. - Bernard Schott, Nov 20 2021

Examples

			The number 70 in reverse is 07 = 7, which is prime.
		

Crossrefs

Cf. A004086, A007500 (primes in this sequence), A076055 (composites in this sequence), A204232 (base-2 analog), A097312.

Programs

  • Maple
    q:= n-> (s-> isprime(parse(cat(s[-i]$i=1..length(s)))))(""||n):
    select(q, [$1..200])[];  # Alois P. Heinz, Aug 22 2021
  • Mathematica
    Select[Range[200], PrimeQ[FromDigits[Reverse[IntegerDigits[#]]]] &] (* Harvey P. Dale, Jun 13 2013 *)
  • PARI
    r(n) = for(x=1,n,y=eval(rev(x));if(isprime(y),print1(x","))) \ Get the reverse of the input string rev(str) = { local(tmp,j,s); tmp = Vec(Str(str)); s=""; forstep(j=length(tmp),1,-1, s=concat(s,tmp[j])); return(s) }
    
  • PARI
    is_A095179(n)=isprime(eval(Strchr(vecextract(Vec(Vecsmall(Str(n))),"-1..1")))) \\ M. F. Hasler, Jan 13 2012
    
  • PARI
    isok(n) = isprime(fromdigits(Vecrev(digits(n)))); \\ Michel Marcus, Aug 22 2021
    
  • Python
    from sympy import isprime
    def ok(n): return isprime(int(str(n)[::-1]))
    print(list(filter(ok, range(1, 173)))) # Michael S. Branicky, Aug 22 2021

Extensions

Offset corrected to 1 by Alonso del Arte, Apr 12 2020

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

A377421 Numbers whose binary reversal is prime and unequal to the original number.

Original entry on oeis.org

6, 10, 11, 12, 13, 14, 20, 22, 23, 24, 25, 26, 28, 29, 34, 37, 40, 41, 43, 44, 46, 47, 48, 50, 52, 53, 55, 56, 58, 61, 62, 67, 68, 71, 74, 77, 80, 82, 83, 86, 88, 91, 92, 94, 96, 97, 100, 101, 104, 106, 110, 112, 113, 115, 116, 121, 122, 124, 131, 134, 136, 142
Offset: 1

Views

Author

Simon R Blow, Oct 27 2024

Keywords

Comments

Contains A080790 and p*2^i for all primes p in A074832 union A080790 and i > 0. - Michael S. Branicky, Oct 29 2024

Examples

			6 = 110_2 is a term since reversed it is 011_2 = 3 which is prime.
7 = 111_2 is not a term since base 2 palindromic numbers are not included.
		

Crossrefs

Supersequence of A080790.

Programs

  • Mathematica
    Select[Range[142],PrimeQ[r=FromDigits[Reverse[IntegerDigits[#,2]],2]]&&r!=#&] (* James C. McMahon, Nov 18 2024 *)
  • Python
    from sympy import isprime
    def ok(n): return (b:=bin(n)[2:]) != (br:=b[::-1]) and isprime(int(br, 2))
    print([k for k in range(1, 143) if ok(k)]) # Michael S. Branicky, Oct 28 2024
    
  • Python
    # alternate program constructing terms directly from primes
    from sympy import primerange
    def auptobits(maxbits):
        alst = []
        for p in primerange(3, 1<Michael S. Branicky, Oct 29 2024

Formula

a = A204232 - A006995 (as sets). - Michael S. Branicky, Oct 29 2024
Showing 1-3 of 3 results.