login
The distance between n! and the nearest perfect square.
2

%I #11 Jul 23 2015 22:13:46

%S 0,0,1,2,1,1,9,1,81,476,225,324,4604,74879,176400,215296,3444736,

%T 11551671,45680444,255004929,1158920361,2657058876,24923993276,

%U 130518272975,97216010329,2430400258225,1553580508516,4666092737476,538347188396016,2137864362693921

%N The distance between n! and the nearest perfect square.

%F a(n) = abs(n!-A260373(n)).

%e 6!=720. The nearest perfect square is 729. The difference between these is 9, so a(6)=9.

%o (PARI) a(n)=abs(n!-round(sqrt(n!))^2) \\ _Charles R Greathouse IV_, Jul 23 2015

%o (Python)

%o from gmpy2 import isqrt

%o A260374_list, g = [0], 1

%o for i in range(1, 1001):

%o ....g *= i

%o ....s = isqrt(g)

%o ....t = g-s**2

%o ....A260374_list.append(int(t if t-s <= 0 else 2*s+1-t)) # _Chai Wah Wu_, Jul 23 2015

%Y Cf. A260373, A260375.

%K nonn

%O 0,4

%A _Otis Tweneboah_, _Pratik Koirala_, _Eugene Fiorini_, _Nathan Fox_, Jul 23 2015