login
Smallest k such that k! > 2^n.
1

%I #19 Feb 19 2024 19:47:47

%S 2,3,3,4,4,5,5,6,6,6,7,7,7,8,8,8,9,9,9,10,10,10,11,11,11,11,12,12,12,

%T 13,13,13,13,14,14,14,14,15,15,15,15,16,16,16,16,17,17,17,17,18,18,18,

%U 18,19,19,19,19,20,20,20,20,20,21,21,21,21,22,22,22,22,23,23,23,23,23,24,24,24,24,24,25,25,25,25,26,26,26,26,26,27,27,27,27

%N Smallest k such that k! > 2^n.

%H Charles R Greathouse IV, <a href="/A269225/b269225.txt">Table of n, a(n) for n = 0..10000</a>

%e a(7) = 6 because 6! = 720 > 2^7 = 128, but 5! = 120 < 128.

%t a[n_] := Block[{v=2^n, k=1}, While[++k! <= v]; k]; Array[a, 93, 0] (* _Giovanni Resta_, Jul 11 2016 *)

%t Module[{nn=30,f},f=Table[{k,k!},{k,nn}];Table[SelectFirst[f,#[[2]]>2^n&],{n,0,100}]][[;;,1]] (* _Harvey P. Dale_, Feb 19 2024 *)

%o (Python)

%o def a269225():

%o ...k = 1

%o ...f = 1

%o ...p = 1

%o ...n = 0

%o ...while True:

%o ......while f<=p:

%o .........k += 1

%o .........f *= k

%o ......yield k

%o ......p *= 2

%o ......n += 1

%o (PARI) a(n)=localprec(19); my(t=log(2)*n, x=ceil(solve(k=1, n/2+5, lngamma(k+1)-t))); while(x!<=2^n, x++); x \\ _Charles R Greathouse IV_, Jul 12 2016

%Y Cf. A003070, A067850, A258782.

%K nonn,easy

%O 0,1

%A _Christian Perfect_, Jul 11 2016