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 A157495 #26 Nov 10 2024 05:15:29 %S A157495 2,2,5,3,2,13,13,3,7,13,31,37,5,7,11,17,23,61,3,7,37,43,2,53,61,37,3, %T A157495 7,73,13,127,31,37,103,5,7,13,19,23,29,79,37,47,157,53,3,67,79,2,193, %U A157495 37,43,97,107,61,7,13,127,241,137,139,37,163,167,277,61,7,13,23,313,29,103 %N A157495 The smallest prime difference between prime(n) and any smaller square. %C A157495 If the only preceding square k such that p-k^2 is prime is 0, then we generate sequence A065377. %H A157495 Robert Israel, <a href="/A157495/b157495.txt">Table of n, a(n) for n = 1..10000</a> %e A157495 The 7th prime is 17. The preceding squares of 17 are 16,9,4,1,0. The differences are 17-16=1, 17-9=8, 17-4=13, 17-1=16 and 17-0=17. Then 4 is the first preceding square of 17 that can be subtracted from 17 to get a prime. So a(7)=13. If we reduce the prime(6)=13 in this fashion, we have 13-9=4, 13-1=12, 13-0=13. This shows that 0 is the first square that can be subtract from 13 to get a prime number. So a(6)=13. %p A157495 A157495 := proc(n) %p A157495 local p,s ; %p A157495 p := ithprime(n) ; %p A157495 s := floor(sqrt(p)) ; %p A157495 while not isprime(p-s^2) do %p A157495 s := s-1; %p A157495 end do; %p A157495 p-s^2 ; %p A157495 end proc: %p A157495 seq(A157495(n),n=1..130) ; # _R. J. Mathar_, Sep 07 2016 %t A157495 Table[SelectFirst[Reverse[p-Range[0,Floor[Sqrt[p]]]^2],PrimeQ],{p, Prime[ Range[80]]}] (* Requires Mathematica version 10 or later *) (* _Harvey P. Dale_, Oct 23 2017 *) %o A157495 (PARI) g(n)= c=0; forprime(x=2,n,for(k=1,n^2,if(issquare(abs(x-k)) && isprime(k), print1(k","); c++; break))); c %Y A157495 Cf. A065377. %K A157495 nonn,look %O A157495 1,1 %A A157495 _Cino Hilliard_, Mar 01 2009 %E A157495 NAME rephrased for clarity. - _R. J. Mathar_, Sep 08 2016