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.
%I A061670 #34 Jan 16 2023 17:48:55 %S A061670 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, %T A061670 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, %U A061670 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 %N A061670 Distance to nearest prime power p^k, k=0 and k >= 2 (A025475). %H A061670 Robert Israel, <a href="/A061670/b061670.txt">Table of n, a(n) for n = 1..10000</a> %H A061670 <a href="/index/Di#distance_to_the_nearest">Index entries for sequences related to distance to nearest element of some set</a> %e A061670 a(12)=3 because 9=3^2 is the nearest power to 12 (12-9=3). %p A061670 N:= 1000: # to get a(1)..a(M) where M is the greatest prime power <= N. %p A061670 Primes:= select(isprime, [2,seq(i,i=3..floor(sqrt(N)))]): %p A061670 Pows:= sort(convert({1,seq(seq(p^e,e=2..floor(log[p](N))),p=Primes)},list)): %p A061670 nP:= nops(Pows): %p A061670 M:= Pows[nP]: %p A061670 V:= Vector(M): %p A061670 V[2]:= 1: %p A061670 for i from 2 to nP-1 do %p A061670 for x from ceil((Pows[i]+Pows[i-1])/2) to floor((Pows[i]+Pows[i+1])/2) do %p A061670 V[x]:= abs(x - Pows[i]) %p A061670 od od: %p A061670 for x from ceil((M+Pows[nP-1])/2) to M do V[x]:= M - x od: %p A061670 convert(V,list); # _Robert Israel_, Mar 23 2018 %o A061670 (PARI) isA025475(n) = {isprimepower(n) && !isprime(n) || n==1} %o A061670 a(n) = {my(k=0); while(!isA025475(n+k) && !isA025475(n-k), k++); k; } \\ _Altug Alkan_, Mar 23 2018 %Y A061670 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). %K A061670 nonn,look %O A061670 1,6 %A A061670 _Michel ten Voorde_, Jun 16 2001 %E A061670 Definition corrected, and more terms from _Robert Israel_, Mar 23 2018