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.

A301630 a(n) = distance of n-th prime to nearest prime power p^k, k=0 and k >= 2 (A025475).

Original entry on oeis.org

1, 1, 1, 1, 2, 3, 1, 3, 2, 2, 1, 5, 8, 6, 2, 4, 5, 3, 3, 7, 8, 2, 2, 8, 16, 20, 18, 14, 12, 8, 1, 3, 9, 11, 20, 18, 12, 6, 2, 4, 10, 12, 22, 24, 28, 30, 32, 20, 16, 14, 10, 4, 2, 5, 1, 7, 13, 15, 12, 8, 6, 4, 18, 22, 24, 26, 12, 6, 4, 6, 8, 2, 6, 12, 18, 22, 28, 36, 40, 48, 58, 60, 70, 72, 73, 69, 63, 55
Offset: 1

Views

Author

Altug Alkan, Mar 24 2018

Keywords

Examples

			a(9) = a(10) = 2 because 5^2 is the nearest prime power (A025475) to prime(9) = 23 and 3^3 is the nearest prime power (A025475) to prime(10) = 29.
		

Crossrefs

There are four different sequences which may legitimately be called "prime powers": A000961 (p^k, k >= 0), A246655 (p^k, k >= 1), A246547 (p^k, k >= 2), A025475 (p^k, k=0 and k >= 2).

Programs

  • Maple
    Primes:= select(isprime, [2,seq(i,i=3..1000,2)]):
    Ppows:= sort([1,seq(seq(p^j, j=2..floor(log[p](1000))),p=Primes)]):
    for n from 1 while Primes[n] < Ppows[-1] do
      i:= ListTools:-BinaryPlace(Ppows,Primes[n]);
      A[n]:= min(Primes[n]-Ppows[i],Ppows[i+1]-Primes[n])
    od:
    seq(A[i],i=1..n-1); # Robert Israel, Mar 26 2018
  • PARI
    isA025475(n) = {isprimepower(n) && !isprime(n) || n==1}
    a(n) = {my(k=1, p=prime(n)); while(!isA025475(p+k) && !isA025475(p-k), k++); k; }

Formula

a(n) = A061670(A000040(n)).