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.

A262463 If n is prime a(n) = n else a(n) = nextprime(reverse(n)), where "next prime" is the smallest prime >= n, see A007918.

Original entry on oeis.org

2, 2, 3, 5, 5, 7, 7, 11, 11, 2, 11, 23, 13, 41, 53, 61, 17, 83, 19, 2, 13, 23, 23, 43, 53, 67, 73, 83, 29, 3, 31, 23, 37, 43, 53, 67, 37, 83, 97, 5, 41, 29, 43, 47, 59, 67, 47, 89, 97, 5, 17, 29, 53, 47, 59, 67, 79, 89, 59, 7, 61, 29, 37, 47, 59, 67, 67, 89, 97, 7, 71, 29, 73, 47, 59, 67, 79, 89, 79, 11, 19, 29
Offset: 1

Views

Author

Maghraoui Abdelkader, Sep 23 2015

Keywords

Examples

			For n=7 a(7)=7.
For n=12, reverse(12)=21; a(12)=nextprime(21)=23.
		

Crossrefs

Programs

  • Mathematica
    Table[Which[PrimeQ[n],n,PrimeQ[IntegerReverse[n]],IntegerReverse[n], True, NextPrime[ IntegerReverse[ n]]],{n,100}] (* Harvey P. Dale, May 12 2018 *)
  • PARI
    rev(n)={d=digits(n); p=""; for(i=1, #d, p=concat(Str(d[i]), p)); return(eval(p))}
    i=0; t=vector(200);
    findn(n)={if(isprime(n),t[i++]=n, a=rev(n); b=nextprime(a); t[i++]=b); }
    for(n=1,200,findn(n)); t

Formula

a(n)=n if n is prime;
else b=reverse(n);
if b is prime a(n)=b else a(n)=nextprime(b);
(using "next prime" function as "smallest prime >= n"; see A007918. )