login
Factorial expansion of sqrt(2) = Sum_{n>=1} a(n)/n!, using greedy algorithm.
4

%I #22 May 22 2022 09:47:48

%S 1,0,2,1,4,4,1,5,0,8,1,11,1,7,8,4,4,4,11,13,1,6,15,13,8,12,22,25,14,9,

%T 13,11,30,9,16,25,3,12,11,2,35,41,29,29,11,27,43,32,1,16,2,5,29,3,2,

%U 30,18,30,32,56,44,38,44,27,4

%N Factorial expansion of sqrt(2) = Sum_{n>=1} a(n)/n!, using greedy algorithm.

%H G. C. Greubel, <a href="/A009949/b009949.txt">Table of n, a(n) for n = 1..10000</a>

%H <a href="https://oeis.org/index/Fa#facbase">Index entries for factorial base representation</a>

%e sqrt(2) = 1 + 0/2! + 2/3! + 1/4! + 4/5! + 4/6! + 1/7! + 5/8! + ...

%p A009949 := proc(a,n) local i,b,c; b := a; c := [ floor(b) ]; for i from 1 to n-1 do b := b-c[ i ]/i!; c := [ op(c), floor(b*(i+1)!) ]; od; c; end:

%t With[{b = Sqrt[2]}, Table[If[n == 1, Floor[b], Floor[n!*b] - n*Floor[(n - 1)!*b]], {n, 1, 100}]] (* _G. C. Greubel_, Dec 10 2018 *)

%o (PARI) default(realprecision, 250); b = sqrt(2); for(n=1, 80, print1(if(n==1, floor(b), floor(n!*b) - n*floor((n-1)!*b)), ", ")) \\ _G. C. Greubel_, Dec 10 2018

%o (PARI) default(realprecision,900); my(t=sqrt(2)); for(n=1,80,t=t*n;print1(floor(t),", ");t=frac(t)); \\ _Joerg Arndt_, Dec 17 2018

%o (Magma) SetDefaultRealField(RealField(250)); [Floor(Sqrt(2))] cat [Floor(Factorial(n)*Sqrt(2)) - n*Floor(Factorial((n-1))*Sqrt(2)) : n in [2..80]]; // _G. C. Greubel_, Dec 10 2018

%o (Sage) b=sqrt(2);

%o def a(n):

%o if (n==1): return floor(b)

%o else: return expand(floor(factorial(n)*b) - n*floor(factorial(n-1)*b))

%o [a(n) for n in (1..80)] # _G. C. Greubel_, Dec 10 2018

%Y Cf. A002193 (decimal expansion), A040000 (continued fraction).

%Y Cf. A067881 (sqrt(3)), A068446 (sqrt(5)), A320839 (sqrt(7)).

%K nonn

%O 1,3

%A _N. J. A. Sloane_, _Bill Gosper_