OFFSET
1,2
COMMENTS
The only n <= 805 where n! + a(n) is not a square is 3. - Robert Israel, Aug 01 2024
LINKS
Robert Israel, Table of n, a(n) for n = 1..805
MAPLE
f:= proc(n) local v, m, p, r;
m:= infinity;
v:= n!;
p:= 1;
do
p:= nextprime(p);
if 2^p >= m+v then break fi;
r:= ceil(v^(1/p))^p - v;
if r < m then m:= r fi;
od;
m
end proc:
map(f, [$1..50]);
MATHEMATICA
nextPerfectPower[n_] := Min@ Table[(Floor[n^(1/k)] + 1)^k, {k, 2, 1 + Floor@ Log2@ n}]; f[n_] := nextPerfectPower[n!] - n!; f[1] = 0; Array[f, 30] (* Robert G. Wilson v, Aug 04 2014 *)
PROG
(PARI)
a(n)=for(k=0, 10^10, s=n!+k; if(ispower(s)||s==1, return(k)))
n=1; while(n<50, print1(a(n), ", "); n++)
(PARI)
a(n)=for(k=1, n!, if(2^k>n!, kk=k; break)); if(kk==1, return(0)); L=List([]); for(i=2, kk, listinsert(L, ceil(n!^(1/i))^i-n!, 1)); listsort(L); L[1]
vector(40, n, a(n)) \\ faster program
CROSSREFS
KEYWORD
nonn
AUTHOR
Derek Orr, Aug 03 2014
EXTENSIONS
a(18) onward from Robert G. Wilson v, Aug 04 2014
STATUS
approved