OFFSET
0,4
COMMENTS
a(n)=0 when n is a cube; between zeros local maxima are of form 3/2 k(k-1).
LINKS
EXAMPLE
a(3) = 2 because the nearest cube to 3 is 1 and distance from 3 to 1 is 2.
MAPLE
A074989 := proc(n) local iscbr ; iroot(n, 3, 'iscbr') ; if iscbr then 0; else iscbr := floor(n^(1/3)) ; min((iscbr+1)^3-n, n-iscbr^3) ; end if; end proc; # R. J. Mathar, Nov 01 2009
MATHEMATICA
dnc[n_]:=Module[{cr=Surd[n, 3]}, Min[n-Floor[cr]^3, Ceiling[cr]^3-n]]; Array[ dnc, 90, 0] (* Harvey P. Dale, Jan 24 2015 *)
PROG
(Haskell)
a074989 0 = 0
a074989 n = min (n - last xs) (head ys - n) where
(xs, ys) = span (< n) a000578_list
-- Reinhard Zumkeller, Nov 28 2011
(Python)
from sympy import integer_nthroot
def A074989(n):
a = integer_nthroot(n, 3)[0]
return min(n-a**3, (a+1)**3-n) # Chai Wah Wu, Mar 31 2021
CROSSREFS
KEYWORD
nonn
AUTHOR
Zak Seidov, Oct 02 2002
EXTENSIONS
a(0) added and offset changed by Reinhard Zumkeller, Nov 28 2011
STATUS
approved