%I #18 Sep 08 2022 08:45:17
%S 1,2,3,4,5,6,3,2,3,4,5,18,3,2,3,4,5,2,7,4,9,4,17,6,3,2,9,10,7,2,7,4,3,
%T 12,7,2,3,38,3,4,11,14,25,4,9,10,5,6,9,4,5,4,7,12,15,4,9,22,17,38,7,4,
%U 5,16,5,2,9,28,11,28,17,14,3,28,9,4,5,12,3,58,5
%N Difference between n^3 and largest m less than n^3, where m > 0 is either a prime or a square.
%H Vincenzo Librandi, <a href="/A104148/b104148.txt">Table of n, a(n) for n = 2..1000</a>
%F a(n) < 2n^(3/2) - 1. Conjecturally a(n) << log^2 n. - _Charles R Greathouse IV_, Jun 03 2013
%e a(5) = 4 because largest square less than 5^3 is 121 and 125 - 121 = 4.
%t lst = {}; Do[k = n^3; a = NextPrime[k, -1]; b = Floor@Sqrt[k - 1]^2; AppendTo[lst, k - Max[a, b]], {n, 2, 82}]; lst (* _Arkadiusz Wesolowski_, Jun 03 2013 *)
%o (Magma) [n^3-Maximum(Isqrt(n^3-1)^2, PreviousPrime(n^3)): n in [2..100]]; // _Bruno Berselli_, Jun 03 2013
%o (PARI) a(n)=n^3-max(sqrtint(n^3-1)^2,precprime(n^3)) \\ _Charles R Greathouse IV_, Jun 03 2013
%K nonn,easy
%O 2,2
%A _Giovanni Teofilatto_, Mar 08 2005
%E Offset corrected by _Michel Marcus_, Jun 03 2013
%E Edited, corrected and extended by _Arkadiusz Wesolowski_, Jun 03 2013