CINXE.COM
A005165 - OEIS
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <html> <head> <link rel="stylesheet" href="/styles.css"> <meta name="format-detection" content="telephone=no"> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta name=viewport content="width=device-width, initial-scale=1"> <meta name="keywords" content="OEIS,integer sequences,Sloane" /> <title>A005165 - OEIS</title> <link rel="search" type="application/opensearchdescription+xml" title="OEIS" href="/oeis.xml"> <script> var myURL = "\/A005165" function redir() { var host = document.location.hostname; if(host != "oeis.org" && host != "127.0.0.1" && !/^([0-9.]+)$/.test(host) && host != "localhost" && host != "localhost.localdomain") { document.location = "https"+":"+"//"+"oeis"+".org/" + myURL; } } function sf() { if(document.location.pathname == "/" && document.f) document.f.q.focus(); } </script> </head> <body bgcolor=#ffffff onload="redir();sf()"> <div class=loginbar> <div class=login> <a href="/login?redirect=%2fA005165">login</a> </div> </div> <div class=center><div class=top> <center> <div class=donors> The OEIS is supported by <a href="http://oeisf.org/#DONATE">the many generous donors to the OEIS Foundation</a>. </div> <div class=banner> <a href="/"><img class=banner border="0" width="600" src="/banner2021.jpg" alt="A005165 - OEIS"></a> </div> <div class="motdbox"> <div class="motd"> <p>Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).</p> </div> <div class="donate"> <div id="donate-button-container"> <div id="donate-button"></div> <script src="https://www.paypalobjects.com/donate/sdk/donate-sdk.js" charset="UTF-8"></script> <script> PayPal.Donation.Button({ env:'production', hosted_button_id:'SVPGSDDCJ734A', image: { src:'https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif', alt:'Donate with PayPal button', title:'PayPal - The safer, easier way to pay online!', } }).render('#donate-button'); </script> </div> <a href="https://oeisf.org/donate/"> <strong>Other ways to Give</strong> </a> </div> </div> </center> </div></div> <div class=center><div class=pagebody> <div class=searchbarcenter> <form name=f action="/search" method="GET"> <div class=searchbargreet> <div class=searchbar> <div class=searchq> <input class=searchbox maxLength=1024 name=q value="" title="Search Query"> </div> <div class=searchsubmit> <input type=submit value="Search" name=go> </div> <div class=hints> <span class=hints><a href="/hints.html">Hints</a></span> </div> </div> <div class=searchgreet> (Greetings from <a href="/welcome">The On-Line Encyclopedia of Integer Sequences</a>!) </div> </div> </form> </div> <div class=sequence> <div class=space1></div> <div class=line></div> <div class=seqhead> <div class=seqnumname> <div class=seqnum> A005165 </div> <div class=seqname> Alternating factorials: n! - (n-1)! + (n-2)! - ... 1!. <br><font size=-1>(Formerly M3892)</font> </div> </div> <div class=scorerefs> 68 </div> </div> <div> <div class=seqdatabox> <div class=seqdata>0, 1, 1, 5, 19, 101, 619, 4421, 35899, 326981, 3301819, 36614981, 442386619, 5784634181, 81393657019, 1226280710981, 19696509177019, 335990918918981, 6066382786809019, 115578717622022981, 2317323290554617019, 48773618881154822981</div> <div class=seqdatalinks> (<a href="/A005165/list">list</a>; <a href="/A005165/graph">graph</a>; <a href="/search?q=A005165+-id:A005165">refs</a>; <a href="/A005165/listen">listen</a>; <a href="/history?seq=A005165">history</a>; <a href="/search?q=id:A005165&fmt=text">text</a>; <a href="/A005165/internal">internal format</a>) </div> </div> </div> <div class=entry> <div class=section> <div class=sectname>OFFSET</div> <div class=sectbody> <div class=sectline>0,4</div> </div> </div> <div class=section> <div class=sectname>COMMENTS</div> <div class=sectbody> <div class=sectline>Conjecture: for n > 2, smallest prime divisor of a(n) > n. - <a href="/wiki/User:Gerald_McGarvey">Gerald McGarvey</a>, Jun 19 2004</div> <div class=sectline>Rebuttal: This is not true; see Zivkovic link (Math. Comp. 68 (1999), pp. 403-409) has demonstrated that 3612703 divides a(n) for all n >= 3612702. - Paul Jobling, Oct 18 2004</div> <div class=sectline>Conjecture: For n>1, a(n) is the number of lattice paths from (0,0) to (n+1,0) that do not cross above y=x or below the x-axis using up-steps +(1,a) and down-steps +(1,-b) where a and b are positive integers. For example, a(3) = 5: [(1,1)(1,1)(1,1)(1,-3)], [(1,1)(1,-1)(1,3)(1,-3)], [(1,1)(1,-1)(1,2)(1,-2)], [(1,1)(1,-1)(1,1)(1,-1)] and [(1,1)(1,1)(1,-1)(1,-1)]. - <a href="/wiki/User:Nicholas_Ham">Nicholas Ham</a>, Aug 23 2015</div> <div class=sectline>Ham's claim is true for n=2. We proceed with a proof for n>2 by induction. On the j-th step, from (j-1,y) to (j,y'), there are j options for y': 0, 1, ..., y-1, y+1, ..., j. Thus there are n! possible paths from (0,0) to x=n that stay between y=0 and y=x. (Then the final step is determined.) However, because +(1,0) is not an allowable step, we cannot land on (n,0) on the n-th step. Therefore, the number of acceptable lattice paths is n! - a(n-1). - <a href="/wiki/User:Danny_Rorabaugh">Danny Rorabaugh</a>, Nov 30 2015</div> </div> </div> <div class=section> <div class=sectname>REFERENCES</div> <div class=sectbody> <div class=sectline>Richard K. Guy, Unsolved Problems in Number Theory, 3rd Edition, Springer, 2004, Section B10, pp. 152-153.</div> <div class=sectline>N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).</div> </div> </div> <div class=section> <div class=sectname>LINKS</div> <div class=sectbody> <div class=sectline>T. D. Noe, <a href="/A005165/b005165.txt">Table of n, a(n) for n = 0..100</a></div> <div class=sectline>Richard K. Guy, <a href="/A005169/a005169_6.pdf">Letter to N. J. A. Sloane</a>, Sep 25 1986.</div> <div class=sectline>Richard K. Guy, <a href="/A005728/a005728.pdf">Letter to N. J. A. Sloane, 1987</a></div> <div class=sectline>Richard K. Guy, <a href="http://www.jstor.org/stable/2322249">The strong law of small numbers</a>. Amer. Math. Monthly 95 (1988), no. 8, 697-712.</div> <div class=sectline>Richard K. Guy, <a href="/A005165/a005165.pdf">The strong law of small numbers</a>. Amer. Math. Monthly 95 (1988), no. 8, 697-712. [Annotated scanned copy]</div> <div class=sectline>Hisanori Mishima, <a href="http://www.asahi-net.or.jp/~KC2H-MSM/mathland/matha1/matha103.htm">Factorizations of many number sequences: 103</a> and <a href="http://www.asahi-net.or.jp/~KC2H-MSM/mathland/matha1/matha130.htm">130</a>.</div> <div class=sectline>Alexsandar Petojevic, <a href="http://www.cs.uwaterloo.ca/journals/JIS/VOL5/Petojevic/petojevic5.html">The Function vM_m(s; a; z) and Some Well-Known Sequences</a>, Journal of Integer Sequences, Vol. 5 (2002), Article 02.1.7.</div> <div class=sectline>Eric Wegrzynowski, <a href="https://web.archive.org/web/20150912143417/http://www.lifl.fr/~wegrzyno/FormulPrem/FormulesPremiers20.html">Séries de factorielles</a>.</div> <div class=sectline>Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/AlternatingFactorial.html">Alternating Factorial</a> and <a href="http://mathworld.wolfram.com/Factorial.html">Factorial</a>.</div> <div class=sectline>Miodrag Živković, <a href="http://dx.doi.org/10.1090/S0025-5718-99-00990-4">The number of primes Sum_{i=1..n} (-1)^(n-i)*i! is finite</a>, Math. Comp. 68 (1999), pp. 403-409.</div> <div class=sectline><a href="/index/Fa#factorial">Index entries for sequences related to factorial numbers</a>.</div> </div> </div> <div class=section> <div class=sectname>FORMULA</div> <div class=sectbody> <div class=sectline>a(0) = 0, a(n) = n! - a(n-1) for n > 0; also a(n) = n*a(n-2) + (n-1)*a(n-1) for n > 1. Sum_{n>=1} Pi^n/a(n) ~ 30.00005. - <a href="/wiki/User:Gerald_McGarvey">Gerald McGarvey</a>, Jun 19 2004</div> <div class=sectline>E.g.f.: 1/(1-x) + exp(-x)*(e*(Ei(1,1)-Ei(1,1-x)) - 1). - <a href="/wiki/User:Robert_Israel">Robert Israel</a>, Dec 01 2015</div> <div class=sectline>a(n) = (-1)^n*(exp(1)*(gamma(n+2)*gamma(-1-n,1)*(-1)^n +Ei(1))-1). - <a href="/wiki/User:Gerry_Martens">Gerry Martens</a>, May 22 2018</div> <div class=sectline>Sum_{n>=1} 1/a(n) = <a href="/A343187" title="Decimal expansion of Sum_{k>=1} 1/af(k), where af is the alternating factorial.">A343187</a>. - <a href="/wiki/User:Amiram_Eldar">Amiram Eldar</a>, Jun 01 2023</div> </div> </div> <div class=section> <div class=sectname>MAPLE</div> <div class=sectbody> <div class=sectline><a href="/A005165" title="Alternating factorials: n! - (n-1)! + (n-2)! - ... 1!.">A005165</a> := proc(n) local i; add((-1)^(n-i)*i!, i=1..n); end;</div> </div> </div> <div class=section> <div class=sectname>MATHEMATICA</div> <div class=sectbody> <div class=sectline>nn=25; With[{fctrls=Range[nn]!}, Table[Abs[Total[Times@@@Partition[ Riffle[ Take[ fctrls, n], {1, -1}], 2]]], {n, nn}]] (* <a href="/wiki/User:Harvey_P._Dale">Harvey P. Dale</a>, Dec 10 2011 *)</div> <div class=sectline>a[0] = 0; a[n_] := n! - a[n - 1]; Array[a, 26, 0] (* <a href="/wiki/User:Robert_G._Wilson_v">Robert G. Wilson v</a>, Aug 06 2012 *)</div> <div class=sectline>RecurrenceTable[{a[n] == n! - a[n - 1], a[0] == 0}, a, {n, 0, 20}] (* <a href="/wiki/User:Eric_W._Weisstein">Eric W. Weisstein</a>, Jul 27 2017 *)</div> <div class=sectline>AlternatingFactorial[Range[0, 20]] (* <a href="/wiki/User:Eric_W._Weisstein">Eric W. Weisstein</a>, Jul 27 2017 *)</div> <div class=sectline>a[n_] = (-1)^n (Exp[1]((-1)^n Gamma[-1-n, 1] Gamma[2+n] - ExpIntegralEi[-1]) - 1)</div> <div class=sectline>Table[a[n] // FullSimplify, {n, 0, 20}] (* <a href="/wiki/User:Gerry_Martens">Gerry Martens</a>, May 22 2018 *)</div> </div> </div> <div class=section> <div class=sectname>PROG</div> <div class=sectbody> <div class=sectline>(PARI) a(n)=if(n<0, 0, sum(k=0, n-1, (-1)^k*(n-k)!))</div> <div class=sectline>(Python)</div> <div class=sectline>a = 0</div> <div class=sectline>f = 1</div> <div class=sectline>for n in range(1, 33):</div> <div class=sectline> print(a, end=", ")</div> <div class=sectline> f *= n</div> <div class=sectline> a = f - a</div> <div class=sectline># <a href="/wiki/User:Alex_Ratushnyak">Alex Ratushnyak</a>, Aug 05 2012</div> <div class=sectline>(PARI) first(m)=vector(m, j, sum(i=0, j-1, ((-1)^i)*(j-i)!)) \\ <a href="/wiki/User:Anders_Hellström">Anders Hellström</a>, Aug 23 2015</div> <div class=sectline>(PARI) a(n)=round((-1)^n*(exp(1)*(gamma(n+2)*incgam(-1-n, 1)*(-1)^n +eint1(1))-1)) \\ <a href="/wiki/User:Gerry_Martens">Gerry Martens</a>, May 22 2018</div> <div class=sectline>(Haskell)</div> <div class=sectline>a005165 n = a005165_list !! n</div> <div class=sectline>a005165_list = 0 : zipWith (-) (tail a000142_list) a005165_list</div> <div class=sectline>-- <a href="/wiki/User:Reinhard_Zumkeller">Reinhard Zumkeller</a>, Jul 21 2013</div> <div class=sectline>(GAP) List([0..30], n->Sum([1..n], i->(-1)^(n-i)*Factorial(i))); # <a href="/wiki/User:Muniru_A_Asiru">Muniru A Asiru</a>, Jun 01 2018</div> </div> </div> <div class=section> <div class=sectname>CROSSREFS</div> <div class=sectbody> <div class=sectline>Cf. <a href="/A000142" title="Factorial numbers: n! = 1*2*3*4*...*n (order of symmetric group S_n, number of permutations of n letters).">A000142</a>, <a href="/A001272" title="Numbers k such that k! - (k-1)! + (k-2)! - (k-3)! + ... - (-1)^k*1! is prime.">A001272</a>, <a href="/A003422" title="Left factorials: !n = Sum_{k=0..n-1} k!.">A003422</a>, <a href="/A071828" title="Primes of the form Sum_{i=1..k} (-1)^(k-i)*i!.">A071828</a>, <a href="/A303697" title="Number T(n,k) of permutations p of [n] whose difference between sum of up-jumps and sum of down-jumps equals k; triangle T(n...">A303697</a>, <a href="/A343187" title="Decimal expansion of Sum_{k>=1} 1/af(k), where af is the alternating factorial.">A343187</a>, <a href="/A359808" title="a(n) is the least prime factor of the alternating factorial n! - (n-1)! + (n-2)! - ... 1! for n > 2; a(1) = a(2) = 1.">A359808</a>.</div> <div class=sectline>Sequence in context: <a href="/A162292" title="Primes of the form k^3-k^2+1, k>0.">A162292</a> <a href="/A321875" title="a(n) = Sum_{d|n} d*d!.">A321875</a> <a href="/A359808" title="a(n) is the least prime factor of the alternating factorial n! - (n-1)! + (n-2)! - ... 1! for n > 2; a(1) = a(2) = 1.">A359808</a> * <a href="/A071828" title="Primes of the form Sum_{i=1..k} (-1)^(k-i)*i!.">A071828</a> <a href="/A280067" title="Number of nX6 0..1 arrays with no element unequal to a strict majority of its horizontal, vertical and antidiagonal neighbor...">A280067</a> <a href="/A158615" title="Expansion of Sum_{n>0} n*n!*x^n/(1-n!*x^n).">A158615</a></div> <div class=sectline>Adjacent sequences: <a href="/A005162" title="Number of alternating sign n X n matrices symmetric with respect to both diagonals.">A005162</a> <a href="/A005163" title="Number of alternating sign n X n matrices that are symmetric about a diagonal.">A005163</a> <a href="/A005164" title="Number of alternating sign 2n+1 X 2n+1 matrices invariant under all symmetries of the square.">A005164</a> * <a href="/A005166" title="a(0) = 1; a(n) = (1 + a(0)^3 + ... + a(n-1)^3)/n (not always integral!).">A005166</a> <a href="/A005167" title="a(n+1) = (1 + a(0)^4 + ... + a(n)^4 )/(n+1) (not always integral!).">A005167</a> <a href="/A005168" title="n-th derivative of x^x at 1, divided by n.">A005168</a></div> </div> </div> <div class=section> <div class=sectname>KEYWORD</div> <div class=sectbody> <div class=sectline><span title="a sequence of nonnegative numbers">nonn</span>,<span title="it is very easy to produce terms of sequence">easy</span>,<span title="an exceptionally nice sequence">nice</span></div> </div> </div> <div class=section> <div class=sectname>AUTHOR</div> <div class=sectbody> <div class=sectline><a href="/wiki/User:N._J._A._Sloane">N. J. A. Sloane</a></div> </div> </div> <div class=section> <div class=sectname>STATUS</div> <div class=sectbody> <div class=sectline>approved</div> </div> </div> </div> <div class=space10></div> </div> </div></div> <p> <div class=footerpad></div> <div class=footer> <center> <div class=bottom> <div class=linksbar> <a href="/">Lookup</a> <a href="/wiki/Welcome"><font color="red">Welcome</font></a> <a href="/wiki/Main_Page"><font color="red">Wiki</font></a> <a href="/wiki/Special:RequestAccount">Register</a> <a href="/play.html">Music</a> <a href="/plot2.html">Plot 2</a> <a href="/demo1.html">Demos</a> <a href="/wiki/Index_to_OEIS">Index</a> <a href="/webcam">WebCam</a> <a href="/Submit.html">Contribute</a> <a href="/eishelp2.html">Format</a> <a href="/wiki/Style_Sheet">Style Sheet</a> <a href="/transforms.html">Transforms</a> <a href="/ol.html">Superseeker</a> <a href="/recent">Recents</a> </div> <div class=linksbar> <a href="/community.html">The OEIS Community</a> </div> <div class=linksbar> Maintained by <a href="http://oeisf.org">The OEIS Foundation Inc.</a> </div> <div class=dbinfo>Last modified December 12 16:33 EST 2024. Contains 378666 sequences.</div> <div class=legal> <a href="/wiki/Legal_Documents">License Agreements, Terms of Use, Privacy Policy</a> </div> </div> </center> </div> </body> </html>