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.

A061670 Distance to nearest prime power p^k, k=0 and k >= 2 (A025475).

Original entry on oeis.org

0, 1, 1, 0, 1, 2, 1, 0, 0, 1, 2, 3, 3, 2, 1, 0, 1, 2, 3, 4, 4, 3, 2, 1, 0, 1, 0, 1, 2, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
Offset: 1

Views

Author

Michel ten Voorde, Jun 16 2001

Keywords

Examples

			a(12)=3 because 9=3^2 is the nearest power to 12 (12-9=3).
		

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
    N:= 1000: # to get a(1)..a(M) where M is the greatest prime power <= N.
    Primes:= select(isprime, [2,seq(i,i=3..floor(sqrt(N)))]):
    Pows:= sort(convert({1,seq(seq(p^e,e=2..floor(log[p](N))),p=Primes)},list)):
    nP:= nops(Pows):
    M:= Pows[nP]:
    V:= Vector(M):
    V[2]:= 1:
    for i from 2 to nP-1 do
      for x from ceil((Pows[i]+Pows[i-1])/2) to floor((Pows[i]+Pows[i+1])/2) do
        V[x]:= abs(x - Pows[i])
    od od:
    for x from ceil((M+Pows[nP-1])/2) to M do V[x]:= M - x od:
    convert(V,list); # Robert Israel, Mar 23 2018
  • PARI
    isA025475(n) = {isprimepower(n) && !isprime(n) || n==1}
    a(n) = {my(k=0); while(!isA025475(n+k) && !isA025475(n-k), k++); k; } \\ Altug Alkan, Mar 23 2018

Extensions

Definition corrected, and more terms from Robert Israel, Mar 23 2018