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.

A386384 Continued fraction expansion of Sum_{k>=0} (-1)^k/(k!)!.

This page as a plain text file.
%I A386384 #44 Aug 27 2025 01:15:37
%S A386384 0,2,179,1,1,1196852626800230399,2,179,1,1,
%T A386384 17377308326435956818596067989554034737368967210468674554156131654360754429984573360106123813424835044026977477398690421454067571097599999999999999999999,
%U A386384 2,179,2,1196852626800230399,1,1,179,2
%N A386384 Continued fraction expansion of Sum_{k>=0} (-1)^k/(k!)!.
%C A386384 The peak terms have the form P(k) = ((k+1)!)! / ((k!)!)^2 - 1. The sequence is an interleaving between the n-th runs of '2' and '1,1' in A386385, and P(A001511(n)+1).
%H A386384 Daniel Hoyt, <a href="/A386384/b386384.txt">Table of n, a(n) for n = 0..39</a>
%H A386384 Daniel Hoyt, <a href="https://doi.org/10.5281/zenodo.16897568">Justification for the explicit formula and program provided</a>, Zenodo, 2025.
%t A386384 ContinuedFraction[Sum[(-1)^k/(k!)!, {k, 0, 6}], 21]
%o A386384 (Python)
%o A386384 import sys #for printing huge factorials
%o A386384 sys.set_int_max_str_digits(0)  # otherwise sys not needed.
%o A386384 def a386384(n):
%o A386384     import math
%o A386384     if n==0: return 0
%o A386384     t=n-1; M=0x18199818
%o A386384     s=[1,1]; h=2; p=0; r=0
%o A386384     def g(u):
%o A386384         nonlocal s,h
%o A386384         while len(s)<u:
%o A386384             q=2 if (h&1)==0 else 1
%o A386384             s+= [q]*((s[h-1]*2)//q); h+=1
%o A386384     while True:
%o A386384         g(p+2)
%o A386384         if s[p]==2: xb='B'; p+=1
%o A386384         elif p+1<len(s) and s[p]==1 and s[p+1]==1: xb='A'; p+=2
%o A386384         else: g(p+2); continue
%o A386384         yb = xb if ((M>>(r&31))&1) else ('A' if xb=='B' else 'B')
%o A386384         L = 2 if yb=='A' else 1
%o A386384         if t < L: return 1 if yb=='A' else 2
%o A386384         t -= L
%o A386384         if t==0:
%o A386384             rr=r+1
%o A386384             K=((rr & -rr).bit_length()-1)+2
%o A386384             A=math.factorial(math.factorial(K+1))
%o A386384             B=math.factorial(math.factorial(K))
%o A386384             return A//(B*B)-1
%o A386384         t-=1; r+=1
%Y A386384 Cf. A001511, A157196, A336810, A386385.
%Y A386384 Cf. A387268 (decimal expansion).
%K A386384 nonn,cofr,new
%O A386384 0,2
%A A386384 _Daniel Hoyt_, Aug 17 2025