cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A240939 Least number k >= 0 such that n! + k is a perfect power.

This page as a plain text file.
%I A240939 #26 Aug 01 2024 18:07:14
%S A240939 0,2,2,1,1,9,1,81,729,225,324,39169,82944,176400,215296,3444736,
%T A240939 26167684,114349225,255004929,1158920361,11638526761,42128246889,
%U A240939 191052974116,97216010329,2430400258225,1553580508516,4666092737476,565986718738441,2137864362693921,5112360635841936
%N A240939 Least number k >= 0 such that n! + k is a perfect power.
%C A240939 The only n <= 805 where n! + a(n) is not a square is 3. - _Robert Israel_, Aug 01 2024
%H A240939 Robert Israel, <a href="/A240939/b240939.txt">Table of n, a(n) for n = 1..805</a>
%p A240939 f:= proc(n) local v,m,p,r;
%p A240939    m:= infinity;
%p A240939    v:= n!;
%p A240939    p:= 1;
%p A240939    do
%p A240939      p:= nextprime(p);
%p A240939      if 2^p >= m+v then break fi;
%p A240939      r:= ceil(v^(1/p))^p - v;
%p A240939      if r < m then m:= r fi;
%p A240939    od;
%p A240939    m
%p A240939 end proc:
%p A240939 map(f, [$1..50]);
%t A240939 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 *)
%o A240939 (PARI)
%o A240939 a(n)=for(k=0,10^10,s=n!+k;if(ispower(s)||s==1,return(k)))
%o A240939 n=1;while(n<50,print1(a(n),", ");n++)
%o A240939 (PARI)
%o A240939 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]
%o A240939 vector(40, n, a(n)) \\ faster program
%Y A240939 Cf. A068869, A240937.
%K A240939 nonn
%O A240939 1,2
%A A240939 _Derek Orr_, Aug 03 2014
%E A240939 a(18) onward from _Robert G. Wilson v_, Aug 04 2014