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\/internal" 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%2finternal">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> </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> <a href="/A005165">A005165</a> </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> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%I M3892 #126 Feb 16 2025 08:32:28 </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%S 0,1,1,5,19,101,619,4421,35899,326981,3301819,36614981,442386619, </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%T 5784634181,81393657019,1226280710981,19696509177019,335990918918981, </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%U 6066382786809019,115578717622022981,2317323290554617019,48773618881154822981 </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%N Alternating factorials: n! - (n-1)! &#43; (n-2)! - ... 1!. </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%C Conjecture: for n &gt; 2, smallest prime divisor of a(n) &gt; n. - _Gerald McGarvey_, Jun 19 2004 </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%C 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 &gt;= 3612702. - Paul Jobling, Oct 18 2004 </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%C Conjecture: For n&gt;1, a(n) is the number of lattice paths from (0,0) to (n&#43;1,0) that do not cross above y=x or below the x-axis using up-steps &#43;(1,a) and down-steps &#43;(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)]. - _Nicholas Ham_, Aug 23 2015 </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%C Ham&#39;s claim is true for n=2. We proceed with a proof for n&gt;2 by induction. On the j-th step, from (j-1,y) to (j,y&#39;), there are j options for y&#39;: 0, 1, ..., y-1, y&#43;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 &#43;(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). - _Danny Rorabaugh_, Nov 30 2015 </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%D Richard K. Guy, Unsolved Problems in Number Theory, 3rd Edition, Springer, 2004, Section B10, pp. 152-153. </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%D N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence). </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%H T. D. Noe, &lt;a href=&#34;/A005165/b005165.txt&#34;&gt;Table of n, a(n) for n = 0..100&lt;/a&gt; </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%H Richard K. Guy, &lt;a href=&#34;/A005169/a005169_6.pdf&#34;&gt;Letter to N. J. A. Sloane&lt;/a&gt;, Sep 25 1986. </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%H Richard K. Guy, &lt;a href=&#34;/A005728/a005728.pdf&#34;&gt;Letter to N. J. A. Sloane, 1987&lt;/a&gt; </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%H Richard K. Guy, &lt;a href=&#34;http://www.jstor.org/stable/2322249&#34;&gt;The strong law of small numbers&lt;/a&gt;. Amer. Math. Monthly 95 (1988), no. 8, 697-712. </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%H Richard K. Guy, &lt;a href=&#34;/A005165/a005165.pdf&#34;&gt;The strong law of small numbers&lt;/a&gt;. Amer. Math. Monthly 95 (1988), no. 8, 697-712. [Annotated scanned copy] </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%H Hisanori Mishima, &lt;a href=&#34;http://www.asahi-net.or.jp/~KC2H-MSM/mathland/matha1/matha103.htm&#34;&gt;Factorizations of many number sequences: 103&lt;/a&gt; and &lt;a href=&#34;http://www.asahi-net.or.jp/~KC2H-MSM/mathland/matha1/matha130.htm&#34;&gt;130&lt;/a&gt;. </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%H Alexsandar Petojevic, &lt;a href=&#34;http://www.cs.uwaterloo.ca/journals/JIS/VOL5/Petojevic/petojevic5.html&#34;&gt;The Function vM_m(s; a; z) and Some Well-Known Sequences&lt;/a&gt;, Journal of Integer Sequences, Vol. 5 (2002), Article 02.1.7. </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%H Eric Wegrzynowski, &lt;a href=&#34;https://web.archive.org/web/20150912143417/http://www.lifl.fr/~wegrzyno/FormulPrem/FormulesPremiers20.html&#34;&gt;S茅ries de factorielles&lt;/a&gt;. </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%H Eric Weisstein&#39;s World of Mathematics, &lt;a href=&#34;https://mathworld.wolfram.com/AlternatingFactorial.html&#34;&gt;Alternating Factorial&lt;/a&gt; and &lt;a href=&#34;https://mathworld.wolfram.com/Factorial.html&#34;&gt;Factorial&lt;/a&gt;. </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%H Miodrag 沤ivkovi膰, &lt;a href=&#34;http://dx.doi.org/10.1090/S0025-5718-99-00990-4&#34;&gt;The number of primes Sum_{i=1..n} (-1)^(n-i)*i! is finite&lt;/a&gt;, Math. Comp. 68 (1999), pp. 403-409. </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%H &lt;a href=&#34;/index/Fa#factorial&#34;&gt;Index entries for sequences related to factorial numbers&lt;/a&gt;. </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%F a(0) = 0, a(n) = n! - a(n-1) for n &gt; 0; also a(n) = n*a(n-2) &#43; (n-1)*a(n-1) for n &gt; 1. Sum_{n&gt;=1} Pi^n/a(n) ~ 30.00005. - _Gerald McGarvey_, Jun 19 2004 </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%F E.g.f.: 1/(1-x) &#43; exp(-x)*(e*(Ei(1,1)-Ei(1,1-x)) - 1). - _Robert Israel_, Dec 01 2015 </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%F a(n) = (-1)^n*(exp(1)*(gamma(n&#43;2)*gamma(-1-n,1)*(-1)^n &#43;Ei(1))-1). - _Gerry Martens_, May 22 2018 </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%F Sum_{n&gt;=1} 1/a(n) = A343187. - _Amiram Eldar_, Jun 01 2023 </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%p A005165 := proc(n) local i; add((-1)^(n-i)*i!,i=1..n); end; </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%t nn=25;With[{fctrls=Range[nn]!},Table[Abs[Total[Times@@@Partition[ Riffle[ Take[ fctrls,n],{1,-1}],2]]],{n,nn}]] (* _Harvey P. Dale_, Dec 10 2011 *) </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%t a[0] = 0; a[n_] := n! - a[n - 1]; Array[a, 26, 0] (* _Robert G. Wilson v_, Aug 06 2012 *) </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%t RecurrenceTable[{a[n] == n! - a[n - 1], a[0] == 0}, a, {n, 0, 20}] (* _Eric W. Weisstein_, Jul 27 2017 *) </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%t AlternatingFactorial[Range[0, 20]] (* _Eric W. Weisstein_, Jul 27 2017 *) </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%t a[n_] = (-1)^n (Exp[1]((-1)^n Gamma[-1-n,1] Gamma[2&#43;n] - ExpIntegralEi[-1]) - 1) </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%t Table[a[n] // FullSimplify, {n, 0, 20}] (* _Gerry Martens_, May 22 2018 *) </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%o (PARI) a(n)=if(n&lt;0,0,sum(k=0,n-1,(-1)^k*(n-k)!)) </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%o (Python) </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%o a = 0 </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%o f = 1 </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%o for n in range(1, 33): </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%o print(a, end=&#34;,&#34;) </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%o f *= n </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%o a = f - a </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%o # _Alex Ratushnyak_, Aug 05 2012 </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%o (PARI) first(m)=vector(m,j,sum(i=0,j-1,((-1)^i)*(j-i)!)) \\ _Anders Hellstr枚m_, Aug 23 2015 </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%o (PARI) a(n)=round((-1)^n*(exp(1)*(gamma(n&#43;2)*incgam(-1-n,1)*(-1)^n &#43;eint1(1))-1)) \\ _Gerry Martens_, May 22 2018 </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%o (Haskell) </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%o a005165 n = a005165_list !! n </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%o a005165_list = 0 : zipWith (-) (tail a000142_list) a005165_list </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%o -- _Reinhard Zumkeller_, Jul 21 2013 </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%o (GAP) List([0..30],n-&gt;Sum([1..n],i-&gt;(-1)^(n-i)*Factorial(i))); # _Muniru A Asiru_, Jun 01 2018 </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%Y Cf. A000142, A001272, A003422, A071828, A303697, A343187, A359808. </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%K nonn,easy,nice </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%O 0,4 </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt>%A _N. J. A. Sloane_ </tt></p> <p style="text-indent: -2em; margin-left: 2em; margin-top: 0; margin-bottom: 0;"><tt></tt></p> </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 March 6 21:02 EST 2025. Contains 381479 sequences.</div> <div class=legal> <a href="/wiki/Legal_Documents">License Agreements, Terms of Use, Privacy Policy</a> </div> </div> </center> </div> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10