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.

A160668 Distance between prime(n) and the next higher power of 10.

This page as a plain text file.
%I A160668 #25 Sep 08 2022 08:45:45
%S A160668 8,7,5,3,89,87,83,81,77,71,69,63,59,57,53,47,41,39,33,29,27,21,17,11,
%T A160668 3,899,897,893,891,887,873,869,863,861,851,849,843,837,833,827,821,
%U A160668 819,809,807,803,801,789,777,773,771,767,761,759,749,743,737,731,729,723
%N A160668 Distance between prime(n) and the next higher power of 10.
%H A160668 G. C. Greubel, <a href="/A160668/b160668.txt">Table of n, a(n) for n = 1..10000</a>
%F A160668 From _Alois P. Heinz_, Dec 08 2017: (Start)
%F A160668 a(n) = 10^A055642(A000040(n)) - A000040(n).
%F A160668 a(n) = A228628(n) + 1 = A061601(A000040(n)) + 1. (End)
%e A160668 a(1)=8 because 10^1=10, and 10-2, 1st prime 2, = 8;
%e A160668 a(5)=89 because 10^2=100 and 100-11, 5th prime 11, = 89.
%p A160668 a:= n-> (p-> 10^length(p)-p)(ithprime(n)):
%p A160668 seq(a(n), n=1..100);  # _Alois P. Heinz_, Dec 08 2017
%t A160668 Table[10^Ceiling[Log[Prime[n]]/Log[10]] - Prime[n], {n, 1, 100}] (* _G. C. Greubel_, May 02 2018 *)
%o A160668 (UBASIC)
%o A160668 20 N=3:print N:C=2
%o A160668 30 A=3:S=sqrt(N)
%o A160668 40 B=N/A 50 if A*B=int(N) then 70
%o A160668 60 A=A+2:if A<S then 40
%o A160668 70 if N=prmdiv(N) then print N;:else 130
%o A160668 80 if alen(N)=1 then print 10^1-N;:P=prmdiv(10^1-N):goto 120
%o A160668 90 if alen(N)=2 then print 10^2-N;:P=prmdiv(10^2-N):goto 120
%o A160668 100 if alen(N)=3 then print 10^3-N;:P=prmdiv(10^3-N):goto 120
%o A160668 110 if alen(N)=4 then print 10^4-N;:P=prmdiv(10^4-N)
%o A160668 120 print P;C:C=C+1:stop
%o A160668 130 N=N+2:S=sqrt(N):goto 40
%o A160668 140 'recipseq, _Enoch Haga_, May 22 2009
%o A160668 (PARI) a(n) = 10^ceil(log(prime(n))/log(10)) - prime(n); \\ _Michel Marcus_, Dec 08 2017
%o A160668 (Magma) [10^(Ceiling(Log(NthPrime(n))/Log(10))) - NthPrime(n): n in [1..30]]; // _G. C. Greubel_, May 02 2018
%Y A160668 Cf. A000040, A055642, A061601, A160669, A160670, A228628.
%K A160668 easy,nonn,base
%O A160668 1,1
%A A160668 _Enoch Haga_, May 23 2009