login
A240939
Least number k >= 0 such that n! + k is a perfect power.
1
0, 2, 2, 1, 1, 9, 1, 81, 729, 225, 324, 39169, 82944, 176400, 215296, 3444736, 26167684, 114349225, 255004929, 1158920361, 11638526761, 42128246889, 191052974116, 97216010329, 2430400258225, 1553580508516, 4666092737476, 565986718738441, 2137864362693921, 5112360635841936
OFFSET
1,2
COMMENTS
The only n <= 805 where n! + a(n) is not a square is 3. - Robert Israel, Aug 01 2024
LINKS
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
Sequence in context: A176602 A322194 A174120 * A016739 A158452 A208929
KEYWORD
nonn
AUTHOR
Derek Orr, Aug 03 2014
EXTENSIONS
a(18) onward from Robert G. Wilson v, Aug 04 2014
STATUS
approved