Factorial: Difference between revisions
imported>Dedhert.Jr Undid revision. Shall this article be protected from IP's editing? |
imported>David Eppstein Undid revision 1356975707 by TheRealStevie (talk) see WP:ELNO #1 |
||
| Line 57: | Line 57: | ||
| style="text-align:left" | {{val|3.041409320|e=64}} | | style="text-align:left" | {{val|3.041409320|e=64}} | ||
|- | |- | ||
| | | 52 | ||
| style="text-align:left" | | | style="text-align:left" | {{Val|8.065817517|e=67}} | ||
{{Val|8.065817517|e=67}} | |||
|- | |- | ||
| 70 | | 70 | ||
| Line 88: | Line 87: | ||
| style="text-align:left" | {{val|2.503898932|e=1000004}} | | style="text-align:left" | {{val|2.503898932|e=1000004}} | ||
|- | |- | ||
| {{val|1000000|fmt=gaps}} | | {{val|1000000|fmt=gaps}}<br />= {{val|e=6}} | ||
| style="text-align: | | style="text-align:right" | {{val|8.263931688|e=5565708}}<br/>≈ 10<sup>{{val|5.5657089172|e=6}}</sup> | ||
|- | |- | ||
| [[googol|{{val|e=100}}]] ||10<sup>{{val|e= | | {{val|e=10}} || 10<sup>{{val|9.5657055186|e=10}}</sup> | ||
|- | |||
| {{val|e=20}} || 10<sup>{{val|19.5657055181|e=20}}</sup> | |||
|- | |||
| {{val|e=50}} || 10<sup>{{val|49.5657055181|e=50}}</sup> | |||
|- | |||
| [[googol|{{val|e=100}}]] || 10<sup>{{val|99.5657055181|e=100}}</sup> | |||
|- | |||
| {{val|e=1000}} || 10<sup>{{val|999.5657055181|e=1000}}</sup> | |||
|} | |} | ||
| Line 98: | Line 105: | ||
\begin{align} | \begin{align} | ||
n! &= n \times (n-1) \times (n-2) \times (n-3) \times \cdots \times 3 \times 2 \times 1 \\ | n! &= n \times (n-1) \times (n-2) \times (n-3) \times \cdots \times 3 \times 2 \times 1 \\ | ||
&= n\times(n-1)!\\ | &= \begin{cases} | ||
1, & \text{if } n = 0 \\ | |||
n \times (n-1)!, & \text{if } n \ge 1. | |||
\end{cases}\\ | |||
\end{align}</math> | \end{align}</math> | ||
For example, | For example, | ||
<math display="block">5! = 5\times 4! = 5 \times 4 \times 3 \times 2 \times 1 = 120. </math> | <math display="block">5! = 5\times 4! = 5 \times 4 \times 3 \times 2 \times 1 = 120.</math> | ||
The value of 0! is 1, according to the convention for an [[empty product]].<ref name="gkp">{{cite book|first1=Ronald L.|last1=Graham|author1-link=Ronald Graham |first2=Donald E.|last2=Knuth|author2-link=Donald Knuth|first3=Oren|last3=Patashnik|author3-link=Oren Patashnik|date=1988|title=Concrete Mathematics|publisher=Addison-Wesley|location=Reading, MA|isbn=0-201-14236-8|title-link=Concrete Mathematics|page=111}}</ref> | The value of 0! is 1, according to the convention for an [[empty product]].<ref name="gkp">{{cite book|first1=Ronald L.|last1=Graham|author1-link=Ronald Graham |first2=Donald E.|last2=Knuth|author2-link=Donald Knuth|first3=Oren|last3=Patashnik|author3-link=Oren Patashnik|date=1988|title=Concrete Mathematics|publisher=Addison-Wesley|location=Reading, MA|isbn=0-201-14236-8|title-link=Concrete Mathematics|page=111}}</ref> | ||
| Line 115: | Line 125: | ||
*In [[Indian mathematics]], one of the earliest known descriptions of factorials comes from the Anuyogadvāra-sūtra,<ref name=datta-singh/> one of the canonical works of [[Jain literature]], which has been assigned dates varying from 300 BCE to 400 CE.<ref>{{cite journal | last = Jadhav | first = Dipak | date = August 2021 | doi = 10.18732/hssa67 | journal = History of Science in South Asia | pages = 209–231 | publisher = University of Alberta Libraries | title = Jaina Thoughts on Unity Not Being a Number | volume = 9| s2cid = 238656716 | doi-access = free }}. See discussion of dating on p. 211.</ref> It separates out the sorted and reversed order of a set of items from the other ("mixed") orders, evaluating the number of mixed orders by subtracting two from the usual product formula for the factorial. The product rule for permutations was also described by 6th-century CE Jain monk [[Jinabhadra]].<ref name=datta-singh>{{cite book | last1 = Datta | first1 = Bibhutibhusan | author1-link = Bibhutibhushan Datta | last2 = Singh | first2 = Awadhesh Narayan | editor1-last = Kolachana | editor1-first = Aditya | editor2-last = Mahesh | editor2-first = K. | editor3-last = Ramasubramanian | editor3-first = K. | contribution = Use of permutations and combinations in India | doi = 10.1007/978-981-13-7326-8_18 | pages = 356–376 | publisher = Springer Singapore | series = Sources and Studies in the History of Mathematics and Physical Sciences | title = Studies in Indian Mathematics and Astronomy: Selected Articles of Kripa Shankar Shukla | year = 2019| isbn = 978-981-13-7325-1 | s2cid = 191141516 }}. Revised by K. S. Shukla from a paper in ''[[Indian Journal of History of Science]]'' 27 (3): 231–249, 1992, {{MR|1189487}}. See p. 363.</ref> Hindu scholars have been using factorial formulas since at least 1150, when [[Bhāskara II]] mentioned factorials in his work [[Līlāvatī]], in connection with a problem of how many ways [[Vishnu]] could hold his four characteristic objects (a [[Shankha|conch shell]], [[Sudarshana Chakra|discus]], [[Kaumodaki|mace]], and [[Sacred lotus in religious art|lotus flower]]) in his four hands, and a similar problem for a ten-handed god.<ref>{{Cite journal |last=Biggs |first=Norman L. |author-link=Norman L. Biggs |date=May 1979 |title=The roots of combinatorics |journal=[[Historia Mathematica]] |volume=6 |issue=2 |pages=109–136 |doi=10.1016/0315-0860(79)90074-0 |doi-access= | mr = 0530622 }}</ref> | *In [[Indian mathematics]], one of the earliest known descriptions of factorials comes from the Anuyogadvāra-sūtra,<ref name=datta-singh/> one of the canonical works of [[Jain literature]], which has been assigned dates varying from 300 BCE to 400 CE.<ref>{{cite journal | last = Jadhav | first = Dipak | date = August 2021 | doi = 10.18732/hssa67 | journal = History of Science in South Asia | pages = 209–231 | publisher = University of Alberta Libraries | title = Jaina Thoughts on Unity Not Being a Number | volume = 9| s2cid = 238656716 | doi-access = free }}. See discussion of dating on p. 211.</ref> It separates out the sorted and reversed order of a set of items from the other ("mixed") orders, evaluating the number of mixed orders by subtracting two from the usual product formula for the factorial. The product rule for permutations was also described by 6th-century CE Jain monk [[Jinabhadra]].<ref name=datta-singh>{{cite book | last1 = Datta | first1 = Bibhutibhusan | author1-link = Bibhutibhushan Datta | last2 = Singh | first2 = Awadhesh Narayan | editor1-last = Kolachana | editor1-first = Aditya | editor2-last = Mahesh | editor2-first = K. | editor3-last = Ramasubramanian | editor3-first = K. | contribution = Use of permutations and combinations in India | doi = 10.1007/978-981-13-7326-8_18 | pages = 356–376 | publisher = Springer Singapore | series = Sources and Studies in the History of Mathematics and Physical Sciences | title = Studies in Indian Mathematics and Astronomy: Selected Articles of Kripa Shankar Shukla | year = 2019| isbn = 978-981-13-7325-1 | s2cid = 191141516 }}. Revised by K. S. Shukla from a paper in ''[[Indian Journal of History of Science]]'' 27 (3): 231–249, 1992, {{MR|1189487}}. See p. 363.</ref> Hindu scholars have been using factorial formulas since at least 1150, when [[Bhāskara II]] mentioned factorials in his work [[Līlāvatī]], in connection with a problem of how many ways [[Vishnu]] could hold his four characteristic objects (a [[Shankha|conch shell]], [[Sudarshana Chakra|discus]], [[Kaumodaki|mace]], and [[Sacred lotus in religious art|lotus flower]]) in his four hands, and a similar problem for a ten-handed god.<ref>{{Cite journal |last=Biggs |first=Norman L. |author-link=Norman L. Biggs |date=May 1979 |title=The roots of combinatorics |journal=[[Historia Mathematica]] |volume=6 |issue=2 |pages=109–136 |doi=10.1016/0315-0860(79)90074-0 |doi-access= | mr = 0530622 }}</ref> | ||
*In the mathematics of the Middle East, the Hebrew mystic book of creation ''[[Sefer Yetzirah]]'', from the [[Talmud|Talmudic period]] (200 to 500 CE), lists factorials up to 7! as part of an investigation into the number of words that can be formed from the [[Hebrew alphabet]].<ref name=katz>{{cite journal | last = Katz | first = Victor J. | author-link = Victor J. Katz | date = June 1994 | issue = 2 | journal = [[For the Learning of Mathematics]] | jstor = 40248112 | pages = 26–30 | title = Ethnomathematics in the classroom | volume = 14}}</ref><ref>[https://en.wikisource.org/wiki/Sefer_Yetzirah#CHAPTER_IV Sefer Yetzirah at Wikisource], Chapter IV, Section 4</ref> Factorials were also studied for similar reasons by 8th-century Arab grammarian [[Al-Khalil ibn Ahmad al-Farahidi]].<ref name=katz/> Arab mathematician [[Ibn al-Haytham]] (also known as Alhazen, c. 965 – c. 1040) was the first to formulate [[Wilson's theorem]] connecting the factorials with the [[prime number]]s.<ref>{{cite journal | last = Rashed | first = Roshdi | author-link = Roshdi Rashed | doi = 10.1007/BF00717654 | issue = 4 | journal = [[Archive for History of Exact Sciences]] | language = fr | mr = 595903 | pages = 305–321 | title = Ibn al-Haytham et le théorème de Wilson | volume = 22 | year = 1980| s2cid = 120885025 }}</ref> | *In the mathematics of the Middle East, the Hebrew mystic book of creation ''[[Sefer Yetzirah]]'', from the [[Talmud|Talmudic period]] (200 to 500 CE), lists factorials up to 7! as part of an investigation into the number of words that can be formed from the [[Hebrew alphabet]].<ref name=katz>{{cite journal | last = Katz | first = Victor J. | author-link = Victor J. Katz | date = June 1994 | issue = 2 | journal = [[For the Learning of Mathematics]] | jstor = 40248112 | pages = 26–30 | title = Ethnomathematics in the classroom | volume = 14}}</ref><ref>[https://en.wikisource.org/wiki/Sefer_Yetzirah#CHAPTER_IV Sefer Yetzirah at Wikisource], Chapter IV, Section 4</ref> Factorials were also studied for similar reasons by 8th-century Arab grammarian [[Al-Khalil ibn Ahmad al-Farahidi]].<ref name=katz/> Arab mathematician [[Ibn al-Haytham]] (also known as Alhazen, c. 965 – c. 1040) was the first to formulate [[Wilson's theorem]] connecting the factorials with the [[prime number]]s.<ref>{{cite journal | last = Rashed | first = Roshdi | author-link = Roshdi Rashed | doi = 10.1007/BF00717654 | issue = 4 | journal = [[Archive for History of Exact Sciences]] | language = fr | mr = 595903 | pages = 305–321 | title = Ibn al-Haytham et le théorème de Wilson | volume = 22 | year = 1980| s2cid = 120885025 }}</ref> | ||
*In Europe, although [[Greek mathematics]] included some combinatorics, and [[Plato]] famously used 5,040 (a factorial) as the population of an ideal community, in part because of its divisibility properties,<ref>{{cite journal | last = Acerbi | first = F. | doi = 10.1007/s00407-003-0067-0 | issue = 6 | journal = [[Archive for History of Exact Sciences]] | jstor = 41134173 | mr = 2004966 | pages = 465–502 | title = On the shoulders of Hipparchus: a reappraisal of ancient Greek combinatorics | volume = 57 | year = 2003| s2cid = 122758966 }}</ref> there is no direct evidence of ancient Greek study of factorials. Instead, the first work on factorials in Europe was by Jewish scholars such as [[Shabbethai Donnolo]], explicating the Sefer Yetzirah passage.<ref>{{cite book|editor1-last=Wilson|editor1-first=Robin|editor2-last=Watkins|editor2-first=John J.|title=Combinatorics: Ancient & Modern|publisher=[[Oxford University Press]]|date=2013|isbn=978-0-19-965659-2|first=Victor J.|last=Katz|author-link=Victor J. Katz|contribution=Chapter 4: Jewish combinatorics|pages=109–121}} See p. 111.</ref> In 1677, British author [[Fabian Stedman]] described the application of factorials to [[change ringing]], a musical art involving the ringing of several tuned bells.<ref>{{cite journal | last = Hunt | first = Katherine | date = May 2018 | doi = 10.1215/10829636-4403136 | issue = 2 | journal = Journal of Medieval and Early Modern Studies | pages = 387–412 | title = The Art of Changes: Bell-Ringing, Anagrams, and the Culture of Combination in Seventeenth-Century England | volume = 48| url = https://ueaeprints.uea.ac.uk/id/eprint/83227/1/Accepted_Mnauscript.pdf }}</ref><ref>{{cite book|last=Stedman|first=Fabian|author-link=Fabian Stedman|title=Campanalogia|year=1677|place=London|pages=6–9}} The publisher is given as "W.S." who may have been William Smith, possibly acting as agent for the [[Ancient Society of College Youths|Society of College Youths]], to which society the "Dedicatory" is addressed.</ref> | *In Europe, although [[Greek mathematics]] included some combinatorics, and [[Plato]] famously used 5,040 (a factorial) as the population of an ideal community, in part because of its divisibility properties,<ref>{{cite journal | last = Acerbi | first = F. | doi = 10.1007/s00407-003-0067-0 | issue = 6 | journal = [[Archive for History of Exact Sciences]] | jstor = 41134173 | mr = 2004966 | pages = 465–502 | title = On the shoulders of Hipparchus: a reappraisal of ancient Greek combinatorics | volume = 57 | year = 2003| s2cid = 122758966 }}</ref> there is no direct evidence of ancient Greek study of factorials. Instead, the first work on factorials in Europe was by Jewish scholars such as [[Shabbethai Donnolo]], explicating the Sefer Yetzirah passage.<ref>{{cite book|editor1-last=Wilson|editor1-first=Robin|editor-link=Robin Wilson (mathematician)|editor2-last=Watkins|editor2-first=John J.|title=Combinatorics: Ancient & Modern|publisher=[[Oxford University Press]]|date=2013|isbn=978-0-19-965659-2|first=Victor J.|last=Katz|author-link=Victor J. Katz|contribution=Chapter 4: Jewish combinatorics|pages=109–121}} See p. 111.</ref> In 1677, British author [[Fabian Stedman]] described the application of factorials to [[change ringing]], a musical art involving the ringing of several tuned bells.<ref>{{cite journal | last = Hunt | first = Katherine | date = May 2018 | doi = 10.1215/10829636-4403136 | issue = 2 | journal = Journal of Medieval and Early Modern Studies | pages = 387–412 | title = The Art of Changes: Bell-Ringing, Anagrams, and the Culture of Combination in Seventeenth-Century England | volume = 48| url = https://ueaeprints.uea.ac.uk/id/eprint/83227/1/Accepted_Mnauscript.pdf }}</ref><ref>{{cite book|last=Stedman|first=Fabian|author-link=Fabian Stedman|title=Campanalogia|year=1677|place=London|pages=6–9}} The publisher is given as "W.S." who may have been William Smith, possibly acting as agent for the [[Ancient Society of College Youths|Society of College Youths]], to which society the "Dedicatory" is addressed.</ref> | ||
From the late 15th century onward, factorials became the subject of study by Western mathematicians. In a 1494 treatise, Italian mathematician [[Luca Pacioli]] calculated factorials up to 11!, in connection with a problem of dining table arrangements.<ref>{{cite book|editor1-last=Wilson|editor1-first=Robin|editor2-last=Watkins|editor2-first=John J.|title=Combinatorics: Ancient & Modern|publisher=[[Oxford University Press]]|date=2013|isbn=978-0-19-965659-2|first=Eberhard|last=Knobloch|author-link=Eberhard Knobloch|contribution=Chapter 5: Renaissance combinatorics|pages=123–145}} See p. 126.</ref> [[Christopher Clavius]] discussed factorials in a 1603 commentary on the work of [[Johannes de Sacrobosco]], and in the 1640s, French polymath [[Marin Mersenne]] published large (but not entirely correct) tables of factorials, up to 64!, based on the work of Clavius.{{sfn|Knobloch|2013|pages=130–133}} The [[power series]] for the [[exponential function]], with the reciprocals of factorials for its coefficients, was first formulated in 1676 by [[Isaac Newton]] in a letter to [[Gottfried Wilhelm Leibniz]].<ref name=exponential-series>{{cite book | last1 = Ebbinghaus | first1 = H.-D. | author1-link = Heinz-Dieter Ebbinghaus | last2 = Hermes | first2 = H. | author2-link = Hans Hermes | last3 = Hirzebruch | first3 = F. | author3-link = Friedrich Hirzebruch | last4 = Koecher | first4 = M. | author4-link = Max Koecher | last5 = Mainzer | first5 = K. | author5-link = Klaus Mainzer | last6 = Neukirch | first6 = J. | author6-link = Jürgen Neukirch | last7 = Prestel | first7 = A. | last8 = Remmert | first8 = R. | author8-link = Reinhold Remmert | doi = 10.1007/978-1-4612-1005-4 | isbn = 0-387-97202-1 | mr = 1066206 | page = 131 | publisher = Springer-Verlag | location = New York | series = Graduate Texts in Mathematics | title = Numbers | url = https://books.google.com/books?id=Z53SBwAAQBAJ&pg=PA131 | volume = 123 | year = 1990}}</ref> Other important works of early European mathematics on factorials include extensive coverage in a 1685 treatise by [[John Wallis]], a study of their approximate values for large values of <math>n</math> by [[Abraham de Moivre]] in 1721, a 1729 letter from [[James Stirling (mathematician)|James Stirling]] to de Moivre stating what became known as [[Stirling's approximation]], and work at the same time by [[Daniel Bernoulli]] and [[Leonhard Euler]] formulating the continuous extension of the factorial function to the [[gamma function]].<ref>{{cite journal | last = Dutka | first = Jacques | doi = 10.1007/BF00389433 | issue = 3 | journal = [[Archive for History of Exact Sciences]] | jstor = 41133918 | mr = 1171521 | pages = 225–249 | title = The early history of the factorial function | volume = 43 | year = 1991| s2cid = 122237769 }}</ref> [[Adrien-Marie Legendre]] included [[Legendre's formula]], describing the exponents in the [[Integer factorization|factorization]] of factorials into [[prime power]]s, in an 1808 text on [[number theory]].<ref>{{cite book|first=Leonard E.|last=Dickson|author-link=Leonard Eugene Dickson|title=History of the Theory of Numbers|title-link=History of the Theory of Numbers|volume=1|publisher=Carnegie Institution of Washington|year=1919|contribution=Chapter IX: Divisibility of factorials and multinomial coefficients|pages=263–278|contribution-url=https://archive.org/details/historyoftheoryo01dick/page/262}} See in particular p. 263.</ref> | From the late 15th century onward, factorials became the subject of study by Western mathematicians. In a 1494 treatise, Italian mathematician [[Luca Pacioli]] calculated factorials up to 11!, in connection with a problem of dining table arrangements.<ref>{{cite book|editor1-last=Wilson|editor1-first=Robin|editor2-last=Watkins|editor2-first=John J.|title=Combinatorics: Ancient & Modern|publisher=[[Oxford University Press]]|date=2013|isbn=978-0-19-965659-2|first=Eberhard|last=Knobloch|author-link=Eberhard Knobloch|contribution=Chapter 5: Renaissance combinatorics|pages=123–145}} See p. 126.</ref> [[Christopher Clavius]] discussed factorials in a 1603 commentary on the work of [[Johannes de Sacrobosco]], and in the 1640s, French polymath [[Marin Mersenne]] published large (but not entirely correct) tables of factorials, up to 64!, based on the work of Clavius.{{sfn|Knobloch|2013|pages=130–133}} The [[power series]] for the [[exponential function]], with the reciprocals of factorials for its coefficients, was first formulated in 1676 by [[Isaac Newton]] in a letter to [[Gottfried Wilhelm Leibniz]].<ref name=exponential-series>{{cite book | last1 = Ebbinghaus | first1 = H.-D. | author1-link = Heinz-Dieter Ebbinghaus | last2 = Hermes | first2 = H. | author2-link = Hans Hermes | last3 = Hirzebruch | first3 = F. | author3-link = Friedrich Hirzebruch | last4 = Koecher | first4 = M. | author4-link = Max Koecher | last5 = Mainzer | first5 = K. | author5-link = Klaus Mainzer | last6 = Neukirch | first6 = J. | author6-link = Jürgen Neukirch | last7 = Prestel | first7 = A. | last8 = Remmert | first8 = R. | author8-link = Reinhold Remmert | doi = 10.1007/978-1-4612-1005-4 | isbn = 0-387-97202-1 | mr = 1066206 | page = 131 | publisher = Springer-Verlag | location = New York | series = Graduate Texts in Mathematics | title = Numbers | url = https://books.google.com/books?id=Z53SBwAAQBAJ&pg=PA131 | volume = 123 | year = 1990}}</ref> Other important works of early European mathematics on factorials include extensive coverage in a 1685 treatise by [[John Wallis]], a study of their approximate values for large values of <math>n</math> by [[Abraham de Moivre]] in 1721, a 1729 letter from [[James Stirling (mathematician)|James Stirling]] to de Moivre stating what became known as [[Stirling's approximation]], and work at the same time by [[Daniel Bernoulli]] and [[Leonhard Euler]] formulating the continuous extension of the factorial function to the [[gamma function]].<ref>{{cite journal | last = Dutka | first = Jacques | doi = 10.1007/BF00389433 | issue = 3 | journal = [[Archive for History of Exact Sciences]] | jstor = 41133918 | mr = 1171521 | pages = 225–249 | title = The early history of the factorial function | volume = 43 | year = 1991| s2cid = 122237769 }}</ref> [[Adrien-Marie Legendre]] included [[Legendre's formula]], describing the exponents in the [[Integer factorization|factorization]] of factorials into [[prime power]]s, in an 1808 text on [[number theory]].<ref>{{cite book|first=Leonard E.|last=Dickson|author-link=Leonard Eugene Dickson|title=History of the Theory of Numbers|title-link=History of the Theory of Numbers|volume=1|publisher=Carnegie Institution of Washington|year=1919|contribution=Chapter IX: Divisibility of factorials and multinomial coefficients|pages=263–278|contribution-url=https://archive.org/details/historyoftheoryo01dick/page/262}} See in particular p. 263.</ref> | ||
| Line 138: | Line 148: | ||
* With {{nowrap|<math>0!=1</math>,}} the recurrence relation for the factorial remains valid {{nowrap|at <math>n=1</math>.}} Therefore, with this convention, a [[recursion|recursive]] computation of the factorial needs to have only the value for zero as a [[Base case (recursion)|base case]], simplifying the computation and avoiding the need for additional special cases.<ref>{{cite conference | last1 = Haberman | first1 = Bruria | last2 = Averbuch | first2 = Haim | editor1-last = Caspersen | editor1-first = Michael E. | editor2-last = Joyce | editor2-first = Daniel T. | editor3-last = Goelman | editor3-first = Don | editor4-last = Utting | editor4-first = Ian | contribution = The case of base cases: Why are they so difficult to recognize? Student difficulties with recursion | doi = 10.1145/544414.544441 | pages = 84–88 | publisher = Association for Computing Machinery | title = Proceedings of the 7th Annual SIGCSE Conference on Innovation and Technology in Computer Science Education, ITiCSE 2002, Aarhus, Denmark, June 24-28, 2002 | year = 2002}}</ref> | * With {{nowrap|<math>0!=1</math>,}} the recurrence relation for the factorial remains valid {{nowrap|at <math>n=1</math>.}} Therefore, with this convention, a [[recursion|recursive]] computation of the factorial needs to have only the value for zero as a [[Base case (recursion)|base case]], simplifying the computation and avoiding the need for additional special cases.<ref>{{cite conference | last1 = Haberman | first1 = Bruria | last2 = Averbuch | first2 = Haim | editor1-last = Caspersen | editor1-first = Michael E. | editor2-last = Joyce | editor2-first = Daniel T. | editor3-last = Goelman | editor3-first = Don | editor4-last = Utting | editor4-first = Ian | contribution = The case of base cases: Why are they so difficult to recognize? Student difficulties with recursion | doi = 10.1145/544414.544441 | pages = 84–88 | publisher = Association for Computing Machinery | title = Proceedings of the 7th Annual SIGCSE Conference on Innovation and Technology in Computer Science Education, ITiCSE 2002, Aarhus, Denmark, June 24-28, 2002 | year = 2002}}</ref> | ||
* Setting <math>0!=1</math> allows for the compact expression of many formulae, such as the [[exponential function]], as a [[power series]]: {{nowrap|<math display=inline> e^x = \sum_{n = 0}^\infty \frac{x^n}{n!}.</math><ref name=exponential-series/>}} | * Setting <math>0!=1</math> allows for the compact expression of many formulae, such as the [[exponential function]], as a [[power series]]: {{nowrap|<math display=inline> e^x = \sum_{n = 0}^\infty \frac{x^n}{n!}.</math><ref name=exponential-series/>}} | ||
* This choice matches the [[gamma function]] {{nowrap|<math>0! = \Gamma(0+1) = 1</math>,}} and the gamma function | * This choice matches the [[gamma function]] {{nowrap|<math>0! = \Gamma(0+1) = 1</math>,}} and the gamma function is defined as a continuous function of complex numbers that does not involve a separate choice at this value.<ref>{{cite book|title=Solved Problems in Analysis: As Applied to Gamma, Beta, Legendre and Bessel Functions|series=Dover Books on Mathematics|first1=Orin J.|last1=Farrell|first2=Bertram|last2=Ross|publisher=Courier Corporation|year=1971|isbn=978-0-486-78308-6|page=10|url=https://books.google.com/books?id=fXPDAgAAQBAJ&pg=PA10}}</ref> | ||
==Applications== | ==Applications== | ||
The earliest uses of the factorial function involve counting [[permutations]]: there are <math>n!</math> different ways of arranging <math>n</math> distinct objects into a sequence.<ref name="ConwayGuy1998">{{Cite book |title=The Book of Numbers |title-link=The Book of Numbers (math book) |last1=Conway |first1=John H. |last2=Guy |first2=Richard |year=1998 |publisher=Springer Science & Business Media |isbn=978-0-387-97993-9 |language=en |author-link=John Horton Conway |author-link2=Richard K. Guy |pages=55–56|contribution=Factorial numbers}}</ref> Factorials appear more broadly in many formulas in [[combinatorics]], to account for different orderings of objects. For instance the [[binomial coefficient]]s <math>\tbinom{n}{k}</math> count the {{nowrap|<math>k</math>-element}} [[combination]]s (subsets of {{nowrap|<math>k</math> elements)}} from a set with {{nowrap|<math>n</math> elements,}} and can be computed from factorials using the formula{{sfn|Graham|Knuth|Patashnik|1988|p=156}} <math display=block>\binom{n}{k}=\frac{n!}{k!(n-k)!}.</math> The [[Stirling numbers of the first kind]] sum to the factorials, and count the permutations {{nowrap|of <math>n</math>}} grouped into subsets with the same numbers of cycles.<ref>{{cite book | last = Riordan | first = John | author-link = John Riordan (mathematician) | mr = 0096594 | page = 76 | publisher = Chapman & Hall | series = Wiley Publications in Mathematical Statistics | title = An Introduction to Combinatorial Analysis | year = 1958}} [https://books.google.com/books?id=Sbb_AwAAQBAJ&pg=PA76 Reprinted], Princeton Legacy Library, Princeton University Press, 2014, {{isbn|9781400854332}}.</ref> Another combinatorial application is in counting [[derangement]]s, permutations that do not leave any element in its original position; the number of derangements of <math>n</math> items is the [[Rounding|nearest integer]] {{nowrap|to <math>n!/e</math>.{{sfn|Graham|Knuth|Patashnik|1988|p=195}}}} | The earliest uses of the factorial function involve counting [[permutations]]: there are <math>n!</math> different ways of arranging <math>n</math> distinct objects into a sequence.<ref name="ConwayGuy1998">{{Cite book |title=The Book of Numbers |title-link=The Book of Numbers (math book) |last1=Conway |first1=John H. |last2=Guy |first2=Richard |year=1998 |publisher=Springer Science & Business Media |isbn=978-0-387-97993-9 |language=en |author-link=John Horton Conway |author-link2=Richard K. Guy |pages=55–56|contribution=Factorial numbers}}</ref> Factorials appear more broadly in many formulas in [[combinatorics]], to account for different orderings of objects. For instance the [[binomial coefficient]]s <math>\tbinom{n}{k}</math> count the {{nowrap|<math>k</math>-element}} [[combination]]s (subsets of {{nowrap|<math>k</math> elements)}} from a set with {{nowrap|<math>n</math> elements,}} and can be computed from factorials using the formula{{sfn|Graham|Knuth|Patashnik|1988|p=156}} <math display=block>\binom{n}{k}=\frac{n!}{k!(n-k)!}.</math> The [[Stirling numbers of the first kind]] sum to the factorials, and count the permutations {{nowrap|of <math>n</math>}} grouped into subsets with the same numbers of cycles.<ref>{{cite book | last = Riordan | first = John | author-link = John Riordan (mathematician) | mr = 0096594 | page = 76 | publisher = Chapman & Hall | series = Wiley Publications in Mathematical Statistics | title = An Introduction to Combinatorial Analysis | year = 1958}} [https://books.google.com/books?id=Sbb_AwAAQBAJ&pg=PA76 Reprinted], Princeton Legacy Library, Princeton University Press, 2014, {{isbn|9781400854332}}.</ref> Another combinatorial application is in counting [[derangement]]s, permutations that do not leave any element in its original position; the number of derangements of <math>n</math> items is the [[Rounding|nearest integer]] {{nowrap|to <math>n!/e</math>.{{sfn|Graham|Knuth|Patashnik|1988|p=195}}}} | ||
In [[algebra]], the factorials arise through the [[binomial theorem]], which uses binomial coefficients to expand powers of sums.{{sfn|Graham|Knuth|Patashnik|1988|p=162}} They also occur in the coefficients used to relate certain families of polynomials to each other, for instance in [[Newton's identities]] for [[symmetric polynomial]]s.<ref>{{cite journal | last = Randić | first = Milan | doi = 10.1007/BF01205340 | issue = 1 | journal = Journal of Mathematical Chemistry | mr = 895533 | pages = 145–152 | title = On the evaluation of the characteristic polynomial via symmetric function theory | volume = 1 | year = 1987| s2cid = 121752631 }}</ref> Their use in counting permutations can also be restated algebraically: the factorials are the [[order of a group|orders]] of finite [[symmetric group]]s.<ref>{{cite book|title=Groups and Characters|first=Victor E.|last=Hill|publisher=Chapman & Hall|year=2000|mr=1739394|isbn=978-1-351-44381-4|page=70|contribution=8.1 Proposition: Symmetric group {{math|''S''<sub>''n''</sub>}}|contribution-url=https://books.google.com/books?id=yjL3DwAAQBAJ&pg=PA70}}</ref> In [[calculus]], factorials occur in [[Faà di Bruno's formula]] for chaining higher derivatives.<ref name=craik/> In [[mathematical analysis]], factorials frequently appear in the denominators of [[power series]], most notably in the series for the [[exponential function]],<ref name=exponential-series/> <math display=block>e^x=1+\frac{x}{1}+\frac{x^2}{2}+\frac{x^3}{6}+\cdots=\sum_{ | In [[algebra]], the factorials arise through the [[binomial theorem]], which uses binomial coefficients to expand powers of sums.{{sfn|Graham|Knuth|Patashnik|1988|p=162}} They also occur in the coefficients used to relate certain families of polynomials to each other, for instance in [[Newton's identities]] for [[symmetric polynomial]]s.<ref>{{cite journal | last = Randić | first = Milan | doi = 10.1007/BF01205340 | issue = 1 | journal = Journal of Mathematical Chemistry | mr = 895533 | pages = 145–152 | title = On the evaluation of the characteristic polynomial via symmetric function theory | volume = 1 | year = 1987| s2cid = 121752631 }}</ref> Their use in counting permutations can also be restated algebraically: the factorials are the [[order of a group|orders]] of finite [[symmetric group]]s.<ref>{{cite book|title=Groups and Characters|first=Victor E.|last=Hill|publisher=Chapman & Hall|year=2000|mr=1739394|isbn=978-1-351-44381-4|page=70|contribution=8.1 Proposition: Symmetric group {{math|''S''<sub>''n''</sub>}}|contribution-url=https://books.google.com/books?id=yjL3DwAAQBAJ&pg=PA70}}</ref> In [[calculus]], factorials occur in [[Faà di Bruno's formula]] for chaining higher derivatives.<ref name=craik/> In [[mathematical analysis]], factorials frequently appear in the denominators of [[power series]], most notably in the series for the [[exponential function]],<ref name=exponential-series/> <math display=block>e^x=1+\frac{x}{1}+\frac{x^2}{2}+\frac{x^3}{6}+\cdots = \sum_{k=0}^{\infty}\frac{x^k}{k!},</math> | ||
and in the coefficients of other [[Taylor series]] (in particular those of the [[trigonometric functions|trigonometric]] and [[hyperbolic functions]]), where they cancel factors of <math>n!</math> coming from the {{nowrap|<math>n</math>th derivative}} {{nowrap|of <math>x^n</math>.<ref>{{cite book|title=Complexity and Criticality|series=Advanced physics texts|volume=1|first1=Kim|last1=Christensen|first2=Nicholas R.|last2=Moloney|publisher=Imperial College Press|year=2005|isbn=978-1-86094-504-5|contribution=Appendix A: Taylor expansion|page=341|contribution-url=https://books.google.com/books?id=bAIM1_EoQu0C&pg=PA341}}</ref>}} This usage of factorials in power series connects back to [[analytic combinatorics]] through the [[exponential generating function]], which for a [[combinatorial class]] with <math>n_i</math> elements of {{nowrap|size <math>i</math>}} is defined as the power series<ref>{{cite book | last = Wilf | first = Herbert S. | author-link = Herbert Wilf | edition = 3rd | isbn = 978-1-56881-279-3 | mr = 2172781 | page = 22 | publisher = A K Peters | location = Wellesley, Massachusetts | title = generatingfunctionology | url = https://books.google.com/books?id=XOPMBQAAQBAJ&pg=PA22 | year = 2006}}</ref> <math display=block>\sum_{ | and in the coefficients of other [[Taylor series]] (in particular those of the [[trigonometric functions|trigonometric]] and [[hyperbolic functions]]), where they cancel factors of <math>n!</math> coming from the {{nowrap|<math>n</math>th derivative}} {{nowrap|of <math>x^n</math>.<ref>{{cite book|title=Complexity and Criticality|series=Advanced physics texts|volume=1|first1=Kim|last1=Christensen|first2=Nicholas R.|last2=Moloney|publisher=Imperial College Press|year=2005|isbn=978-1-86094-504-5|contribution=Appendix A: Taylor expansion|page=341|contribution-url=https://books.google.com/books?id=bAIM1_EoQu0C&pg=PA341}}</ref>}} This usage of factorials in power series connects back to [[analytic combinatorics]] through the [[exponential generating function]], which for a [[combinatorial class]] with <math>n_i</math> elements of {{nowrap|size <math>i</math>}} is defined as the power series<ref>{{cite book | last = Wilf | first = Herbert S. | author-link = Herbert Wilf | edition = 3rd | isbn = 978-1-56881-279-3 | mr = 2172781 | page = 22 | publisher = A K Peters | location = Wellesley, Massachusetts | title = generatingfunctionology | url = https://books.google.com/books?id=XOPMBQAAQBAJ&pg=PA22 | year = 2006}}</ref> <math display=block>\sum_{k=0}^{\infty} \frac{x^k n_k}{k!}.</math> | ||
In [[number theory]], the most salient property of factorials is the [[divisibility]] of <math>n!</math> by all positive integers up {{nowrap|to <math>n</math>,}} described more precisely for prime factors by [[Legendre's formula]]. It follows that arbitrarily large [[prime number]]s can be found as the prime factors of the numbers | In [[number theory]], the most salient property of factorials is the [[divisibility]] of <math>n!</math> by all positive integers up {{nowrap|to <math>n</math>,}} described more precisely for prime factors by [[Legendre's formula]]. It follows that arbitrarily large [[prime number]]s can be found as the prime factors of the numbers | ||
| Line 152: | Line 162: | ||
==Properties== | ==Properties== | ||
[[File:Mplwp factorial stirling loglog2.svg|thumb|upright=1.6|Comparison of the factorial, Stirling's approximation, and the simpler approximation {{nowrap|<math>(n/e)^n</math>,}} on a doubly logarithmic scale]] | |||
[[File:Stirling series relative error.svg|thumb|upright=1.6|[[Relative error]] in a truncated Stirling series vs. number of terms]] | |||
===Growth and approximation=== | ===Growth and approximation=== | ||
{{main|Stirling's approximation}} | {{main|Stirling's approximation}} | ||
| Line 162: | Line 172: | ||
More carefully bounding the sum both above and below by an integral, using the [[trapezoid rule]], shows that this estimate needs a correction factor proportional {{nowrap|to <math>\sqrt n</math>.}} The constant of proportionality for this correction can be found from the [[Wallis product]], which expresses <math>\pi</math> as a limiting ratio of factorials and powers of two. The result of these corrections is [[Stirling's approximation]]:<ref>{{cite book | last = Palmer | first = Edgar M. | contribution = Appendix II: Stirling's formula | isbn = 0-471-81577-2 | location = Chichester | mr = 795795 | pages = 127–128 | publisher = John Wiley & Sons | series = Wiley-Interscience Series in Discrete Mathematics | title = Graphical Evolution: An introduction to the theory of random graphs | year = 1985}}</ref> | More carefully bounding the sum both above and below by an integral, using the [[trapezoid rule]], shows that this estimate needs a correction factor proportional {{nowrap|to <math>\sqrt n</math>.}} The constant of proportionality for this correction can be found from the [[Wallis product]], which expresses <math>\pi</math> as a limiting ratio of factorials and powers of two. The result of these corrections is [[Stirling's approximation]]:<ref>{{cite book | last = Palmer | first = Edgar M. | contribution = Appendix II: Stirling's formula | isbn = 0-471-81577-2 | location = Chichester | mr = 795795 | pages = 127–128 | publisher = John Wiley & Sons | series = Wiley-Interscience Series in Discrete Mathematics | title = Graphical Evolution: An introduction to the theory of random graphs | year = 1985}}</ref> | ||
<math display="block">n!\sim\sqrt{2\pi n}\left(\frac{n}{e}\right)^n\,.</math> | <math display="block">n!\sim\sqrt{2\pi n}\left(\frac{n}{e}\right)^n\,.</math> | ||
Here, the <math>\sim</math> symbol means that, as <math>n</math> goes to infinity, the ratio between the left and right sides approaches | Here, the <math>\sim</math> symbol means that, as <math>n</math> goes to infinity, the ratio between the left and right sides approaches <math>1</math> in the [[Limit (mathematics)|limit]]. | ||
Stirling's formula provides the first term in an [[asymptotic series]] that becomes even more accurate when taken to greater numbers of terms:<ref name="asymptotic">{{cite journal | last1 = Chen | first1 = Chao-Ping | last2 = Lin | first2 = Long | doi = 10.1016/j.aml.2012.06.025 | issue = 12 | journal = Applied Mathematics Letters | mr = 2967837 | pages = 2322–2326 | title = Remarks on asymptotic expansions for the gamma function | volume = 25 | year = 2012| doi-access = free }}</ref> | Stirling's formula provides the first term in an [[asymptotic series]] that becomes even more accurate when taken to greater numbers of terms:<ref name="asymptotic">{{cite journal | last1 = Chen | first1 = Chao-Ping | last2 = Lin | first2 = Long | doi = 10.1016/j.aml.2012.06.025 | issue = 12 | journal = Applied Mathematics Letters | mr = 2967837 | pages = 2322–2326 | title = Remarks on asymptotic expansions for the gamma function | volume = 25 | year = 2012| doi-access = free }}</ref> | ||
<math display="block"> | <math display="block"> | ||
n! \sim \sqrt{2\pi n}\left(\frac{n}{e}\right)^n \left(1 +\frac{1}{12n}+\frac{1}{288n^2} - \frac{139}{51840n^3} -\frac{571}{2488320n^4}+ \cdots \right).</math> | n! \sim \sqrt{2\pi n}\left(\frac{n}{e}\right)^n \left(1 +\frac{1}{12n}+\frac{1}{288n^2} - \frac{139}{51840n^3} -\frac{571}{2488320n^4}+ \cdots \right).</math> | ||
An alternative version | An alternative version (the approximation derived directly from the [[Euler–Maclaurin formula]]) converges faster because it only requires odd exponents in the correction terms:<ref name=asymptotic/> | ||
<math display=block> | <math display=block> | ||
n! \sim \sqrt{2\pi n}\left(\frac{n}{e}\right)^n \exp\left(\frac{1}{12n} - \frac{1}{360n^3} + \frac{1}{1260n^5} -\frac{1}{1680n^7}+ \cdots \right).</math> | n! \sim \sqrt{2\pi n}\left(\frac{n}{e}\right)^n \exp\left(\frac{1}{12n} - \frac{1}{360n^3} + \frac{1}{1260n^5} -\frac{1}{1680n^7}+ \cdots \right).</math> | ||
| Line 172: | Line 182: | ||
The [[binary logarithm]] of the factorial, used to analyze [[comparison sort]]ing, can be very accurately estimated using Stirling's approximation. In the formula below, the <math>O(1)</math> term invokes [[big O notation]].<ref name=knuth-sorting>{{cite book|title=The Art of Computer Programming, Volume 3: Sorting and Searching|first=Donald E.|last=Knuth|author-link=Donald Knuth|edition=2nd|publisher=Addison-Wesley|year=1998|isbn=978-0-321-63578-5|page=182|url=https://books.google.com/books?id=cYULBAAAQBAJ&pg=PA182}}</ref> | The [[binary logarithm]] of the factorial, used to analyze [[comparison sort]]ing, can be very accurately estimated using Stirling's approximation. In the formula below, the <math>O(1)</math> term invokes [[big O notation]].<ref name=knuth-sorting>{{cite book|title=The Art of Computer Programming, Volume 3: Sorting and Searching|first=Donald E.|last=Knuth|author-link=Donald Knuth|edition=2nd|publisher=Addison-Wesley|year=1998|isbn=978-0-321-63578-5|page=182|url=https://books.google.com/books?id=cYULBAAAQBAJ&pg=PA182}}</ref> | ||
<math display=block>\log_2 n! = n\log_2 n- | <math display=block>\log_2 n! = n\log_2 n- n \log_2 e + \frac12\log_2 n + O(1).</math> | ||
===Divisibility and digits=== | ===Divisibility and digits=== | ||
| Line 178: | Line 188: | ||
The product formula for the factorial implies that <math>n!</math> is [[divisible]] by all [[prime number]]s that are at {{nowrap|most <math>n</math>,}} and by no larger prime numbers.<ref name=beiler>{{cite book|title=Recreations in the Theory of Numbers: The Queen of Mathematics Entertains|series=Dover Recreational Math Series|first=Albert H.|last=Beiler|publisher=Courier Corporation|year=1966|edition=2nd|isbn=978-0-486-21096-4|page=49|url=https://books.google.com/books?id=NbbbL9gMJ88C&pg=PA49}}</ref> More precise information about its divisibility is given by [[Legendre's formula]], which gives the exponent of each prime <math>p</math> in the prime factorization of <math>n!</math> as<ref>{{harvnb|Chvátal|2021}}. "1.4: Legendre's formula". pp. 6–7.</ref><ref name=padic>{{cite book | last = Robert | first = Alain M. | author-link = Alain M. Robert | contribution = 3.1: The {{nowrap|<math>p</math>-adic}} valuation of a factorial | doi = 10.1007/978-1-4757-3254-2 | isbn = 0-387-98669-3 | mr = 1760253 | pages = 241–242 | publisher = Springer-Verlag | location = New York | series = [[Graduate Texts in Mathematics]] | title = A Course in {{nowrap|<math>p</math>-adic}} Analysis | volume = 198 | year = 2000}}</ref> | The product formula for the factorial implies that <math>n!</math> is [[divisible]] by all [[prime number]]s that are at {{nowrap|most <math>n</math>,}} and by no larger prime numbers.<ref name=beiler>{{cite book|title=Recreations in the Theory of Numbers: The Queen of Mathematics Entertains|series=Dover Recreational Math Series|first=Albert H.|last=Beiler|publisher=Courier Corporation|year=1966|edition=2nd|isbn=978-0-486-21096-4|page=49|url=https://books.google.com/books?id=NbbbL9gMJ88C&pg=PA49}}</ref> More precise information about its divisibility is given by [[Legendre's formula]], which gives the exponent of each prime <math>p</math> in the prime factorization of <math>n!</math> as<ref>{{harvnb|Chvátal|2021}}. "1.4: Legendre's formula". pp. 6–7.</ref><ref name=padic>{{cite book | last = Robert | first = Alain M. | author-link = Alain M. Robert | contribution = 3.1: The {{nowrap|<math>p</math>-adic}} valuation of a factorial | doi = 10.1007/978-1-4757-3254-2 | isbn = 0-387-98669-3 | mr = 1760253 | pages = 241–242 | publisher = Springer-Verlag | location = New York | series = [[Graduate Texts in Mathematics]] | title = A Course in {{nowrap|<math>p</math>-adic}} Analysis | volume = 198 | year = 2000}}</ref> | ||
<math display=block>\sum_{i=1}^\infty \left \lfloor \frac n {p^i} \right \rfloor=\frac{n - s_p(n)}{p - 1}.</math> | <math display=block>\sum_{i=1}^\infty \left \lfloor \frac n {p^i} \right \rfloor=\frac{n - s_p(n)}{p - 1}.</math> | ||
Here <math>s_p(n)</math> denotes the sum of the {{nowrap|[[radix|base]]-<math>p</math>}} digits {{nowrap|of <math>n</math> | Here <math>s_p(n)</math> denotes the sum of the {{nowrap|[[radix|base]]-<math>p</math>}} digits {{nowrap|of <math>n</math>.}} The exponent given by this formula can more technically be called the [[p-adic valuation|{{mvar|p}}-adic valuation]] of the factorial.<ref name=padic/> Applying Legendre's formula to the product formula for [[binomial coefficient]]s produces [[Kummer's theorem]], a similar result on the exponent of each prime in the factorization of a binomial coefficient.<ref>{{cite book | last1 = Peitgen | author1-link=Heinz-Otto Peitgen | first1 = Heinz-Otto | last2 = Jürgens | first2 = Hartmut | author2-link = Hartmut Jürgens | last3 = Saupe | first3 = Dietmar | author3-link = Dietmar Saupe | contribution = Kummer's result and Legendre's identity | doi = 10.1007/b97624 | location = New York | pages = 399–400 | publisher = Springer | title = Chaos and Fractals: New Frontiers of Science | year = 2004| isbn=978-1-4684-9396-2 }}</ref> Grouping the prime factors of the factorial into [[prime power]]s in different ways produces the [[multiplicative partitions of factorials]].<ref>{{Cite journal|last1=Alladi|first1=Krishnaswami|last2=Grinstead|first2=Charles|authorlink1=Krishnaswami Alladi |title=On the decomposition of n! into prime powers|journal=[[Journal of Number Theory]]|year=1977 |language=en|volume=9|issue=4|pages=452–458|doi=10.1016/0022-314x(77)90006-3|doi-access=free}}</ref> | ||
The special case of Legendre's formula for <math>p=5</math> gives the number of [[trailing zero#Factorial|trailing zeros]] in the decimal representation of the factorials.<ref name=koshy/> According to this formula, the number of zeros can be obtained by subtracting the base-5 digits of <math>n</math> from <math>n</math>, and dividing the result by four.<ref>{{cite OEIS|A027868|Number of trailing zeros in n!; highest power of 5 dividing n!}}</ref> Legendre's formula implies that the exponent of the prime <math>p=2</math> is always larger than the exponent for {{nowrap|<math>p=5</math>,}} so each factor of five can be paired with a factor of two to produce one of these trailing zeros.<ref name=koshy>{{cite book|title=Elementary Number Theory with Applications|first=Thomas|last=Koshy|edition=2nd|publisher=Elsevier|year=2007|isbn=978-0-08-054709-1|contribution=Example 3.12|page=178|contribution-url=https://books.google.com/books?id=d5Z5I3gnFh0C&pg=PA178}}</ref> The leading digits of the factorials are distributed according to [[Benford's law]].<ref>{{cite journal | last = Diaconis | first = Persi | author-link = Persi Diaconis | doi = 10.1214/aop/1176995891 | issue = 1 | journal = [[Annals of Probability]] | mr = 422186 | pages = 72–81 | title = The distribution of leading digits and uniform distribution mod 1 | volume = 5 | year = 1977| doi-access = free }}</ref> Every sequence of digits, in any base, is the sequence of initial digits of some factorial number in that base.<ref>{{cite journal|last=Bird|first=R. S.|author-link=Richard Bird (computer scientist)|doi=10.1080/00029890.1972.11993051|journal=[[The American Mathematical Monthly]]|jstor=2978087|mr=302553|pages=367–370|title=Integers with given initial digits|volume=79|year=1972|issue=4}}</ref> | The special case of Legendre's formula for <math>p=5</math> gives the number of [[trailing zero#Factorial|trailing zeros]] in the decimal representation of the factorials.<ref name=koshy/> According to this formula, the number of zeros can be obtained by subtracting the base-5 digits of <math>n</math> from <math>n</math>, and dividing the result by four.<ref>{{cite OEIS|A027868|Number of trailing zeros in n!; highest power of 5 dividing n!}}</ref> Legendre's formula implies that the exponent of the prime <math>p=2</math> is always larger than the exponent for {{nowrap|<math>p=5</math>,}} so each factor of five can be paired with a factor of two to produce one of these trailing zeros.<ref name=koshy>{{cite book|title=Elementary Number Theory with Applications|first=Thomas|last=Koshy|edition=2nd|publisher=Elsevier|year=2007|isbn=978-0-08-054709-1|contribution=Example 3.12|page=178|contribution-url=https://books.google.com/books?id=d5Z5I3gnFh0C&pg=PA178}}</ref> The leading digits of the factorials are distributed according to [[Benford's law]].<ref>{{cite journal | last = Diaconis | first = Persi | author-link = Persi Diaconis | doi = 10.1214/aop/1176995891 | issue = 1 | journal = [[Annals of Probability]] | mr = 422186 | pages = 72–81 | title = The distribution of leading digits and uniform distribution mod 1 | volume = 5 | year = 1977| doi-access = free }}</ref> Every sequence of digits, in any base, is the sequence of initial digits of some factorial number in that base.<ref>{{cite journal|last=Bird|first=R. S.|author-link=Richard Bird (computer scientist)|doi=10.1080/00029890.1972.11993051|journal=[[The American Mathematical Monthly]]|jstor=2978087|mr=302553|pages=367–370|title=Integers with given initial digits|volume=79|year=1972|issue=4}}</ref> | ||
| Line 189: | Line 199: | ||
===Continuous interpolation and non-integer generalization=== | ===Continuous interpolation and non-integer generalization=== | ||
[[File:Generalized factorial function more infos.svg|thumb|upright=1. | [[File:Generalized factorial function more infos.svg|thumb|upright=1.65|The gamma function (shifted one unit left to match the facto­rials) continuously interpolates the factorial to non-integer values]] | ||
[[File:Gamma abs 3D.png|thumb|Absolute values of the complex gamma function, showing poles at non-positive integers]] | [[File:Gamma abs 3D.png|thumb|Absolute values of the complex gamma function, showing poles at non-positive integers]] | ||
{{Main|Gamma function}} | {{Main|Gamma function}} | ||
| Line 203: | Line 213: | ||
The same integral converges more generally for any [[complex number]] <math>z</math> whose real part is positive. It can be extended to the non-integer points in the rest of the [[complex plane]] by solving for Euler's [[reflection formula]] | The same integral converges more generally for any [[complex number]] <math>z</math> whose real part is positive. It can be extended to the non-integer points in the rest of the [[complex plane]] by solving for Euler's [[reflection formula]] | ||
<math display=block>\Gamma(z)\Gamma(1-z)=\frac{\pi}{\sin\pi z}.</math> | <math display=block>\Gamma(z)\Gamma(1-z)=\frac{\pi}{\sin\pi z}.</math> | ||
However, this formula cannot be used at integers because, for them, the <math>\sin\pi z</math> term would produce a [[division by zero]]. The result of this extension process is an [[analytic function]], the [[analytic continuation]] of the integral formula for the gamma function. It has a nonzero value at all complex numbers, except for the non-positive integers where it has [[Zeros and poles|simple poles]]. Correspondingly, this provides a definition for the factorial at all complex numbers other than the negative integers.<ref name=borwein-corless>{{cite journal | last1 = Borwein | first1 = Jonathan M. | author1-link = Jonathan Borwein | last2 = Corless | first2 = Robert M. | doi = 10.1080/00029890.2018.1420983 | issue = 5 | journal = [[The American Mathematical Monthly]] | mr = 3785875 | pages = 400–424 | title = Gamma and factorial in the ''Monthly'' | volume = 125 | year = 2018| arxiv = 1703.05349 | s2cid = 119324101 }}</ref> | However, this formula cannot be used at integers because, for them, the <math>\sin\pi z</math> term would produce a [[division by zero]]. The result of this extension process is an [[analytic function]] (more specifically a [[meromorphic function]]), the [[analytic continuation]] of the integral formula for the gamma function. It has a nonzero value at all complex numbers, except for the non-positive integers where it has [[Zeros and poles|simple poles]]. Correspondingly, this provides a definition for the factorial at all complex numbers other than the negative integers.<ref name=borwein-corless>{{cite journal | last1 = Borwein | first1 = Jonathan M. | author1-link = Jonathan Borwein | last2 = Corless | first2 = Robert M. | doi = 10.1080/00029890.2018.1420983 | issue = 5 | journal = [[The American Mathematical Monthly]] | mr = 3785875 | pages = 400–424 | title = Gamma and factorial in the ''Monthly'' | volume = 125 | year = 2018| arxiv = 1703.05349 | s2cid = 119324101 }}</ref> | ||
One property of the gamma function, distinguishing it from other continuous interpolations of the factorials, is given by the [[Bohr–Mollerup theorem]], which states that the gamma function (offset by one) is the only [[log-convex]] function on the positive real numbers that interpolates the factorials and obeys the same functional equation. A related uniqueness theorem of [[Helmut Wielandt]] states that the complex gamma function and its scalar multiples are the only [[holomorphic function]]s on the positive complex half-plane that obey the functional equation and remain bounded for complex numbers with real part between 1 and 2.<ref>{{cite journal | last = Remmert | first = Reinhold | author-link = Reinhold Remmert | doi = 10.1080/00029890.1996.12004726 | issue = 3 | journal = [[The American Mathematical Monthly]] | jstor = 2975370 | mr = 1376175 | pages = 214–220 | title = Wielandt's theorem about the {{nowrap|<math>\Gamma</math>-function}} | volume = 103 | year = 1996}}</ref> | One property of the gamma function, distinguishing it from other continuous interpolations of the factorials, is given by the [[Bohr–Mollerup theorem]], which states that the gamma function (offset by one) is the only [[log-convex]] function on the positive real numbers that interpolates the factorials and obeys the same functional equation. A related uniqueness theorem of [[Helmut Wielandt]] states that the complex gamma function and its scalar multiples are the only [[holomorphic function]]s on the positive complex half-plane that obey the functional equation and remain bounded for complex numbers with real part between 1 and 2.<ref>{{cite journal | last = Remmert | first = Reinhold | author-link = Reinhold Remmert | doi = 10.1080/00029890.1996.12004726 | issue = 3 | journal = [[The American Mathematical Monthly]] | jstor = 2975370 | mr = 1376175 | pages = 214–220 | title = Wielandt's theorem about the {{nowrap|<math>\Gamma</math>-function}} | volume = 103 | year = 1996}}</ref> | ||
Other complex functions that interpolate the factorial values include [[Hadamard's gamma function]], which is an [[entire function]] over all the complex numbers, including the non-positive integers.<ref>{{cite book|first=J.|last=Hadamard|author-link=Jacques Hadamard|chapter=Sur l'expression du produit {{math|1·2·3· · · · ·(''n''−1)}} par une fonction entière|title=Œuvres de Jacques Hadamard|publisher=Centre National de la Recherche Scientifiques|location=Paris|date=1968|chapter-url=http://www.luschny.de/math/factorial/hadamard/HadamardFactorial.pdf|orig-date=1894|language=fr}} | Other complex functions that interpolate the factorial values include [[Hadamard's gamma function]], which is an [[entire function]] over all the complex numbers, including the non-positive integers.<ref>{{cite book|first=J.|last=Hadamard|author-link=Jacques Hadamard|chapter=Sur l'expression du produit {{math|1·2·3· · · · ·(''n''−1)}} par une fonction entière|title=Œuvres de Jacques Hadamard|publisher=Centre National de la Recherche Scientifiques|location=Paris|date=1968|chapter-url=http://www.luschny.de/math/factorial/hadamard/HadamardFactorial.pdf|orig-date=1894|language=fr}} | ||
</ref><ref>{{cite journal | last = Alzer | first = Horst | doi = 10.1007/s12188-008-0009-5 | issue = 1 | journal = Abhandlungen aus dem Mathematischen Seminar der Universität Hamburg | mr = 2541340 | pages = 11–23 | title = A superadditive property of Hadamard's gamma function | volume = 79 | year = 2009| s2cid = 123691692 }}</ref> In the [[p-adic number|{{mvar|p}}-adic number]]s, it is not possible to continuously interpolate the factorial function directly, because the factorials of large integers (a dense subset of the {{mvar|p}}- | </ref><ref>{{cite journal | last = Alzer | first = Horst | doi = 10.1007/s12188-008-0009-5 | issue = 1 | journal = Abhandlungen aus dem Mathematischen Seminar der Universität Hamburg | mr = 2541340 | pages = 11–23 | title = A superadditive property of Hadamard's gamma function | volume = 79 | year = 2009| s2cid = 123691692 }}</ref> In the [[p-adic number|{{mvar|p}}-adic number]]s, it is not possible to continuously interpolate the factorial function directly, because the factorials of large integers (a [[dense subset]] of the {{mvar|p}}-adic integers) converge to zero according to Legendre's formula, forcing any continuous function that is close to their values to be zero everywhere. Instead, the [[p-adic gamma function|{{mvar|p}}-adic gamma function]] provides a continuous interpolation of a modified form of the factorial, omitting the factors in the factorial that are divisible by {{mvar|p}}.<ref>{{harvnb|Robert|2000}}. "7.1: The gamma function {{nowrap|<math>\Gamma_p</math>".}} pp. 366–385.</ref> | ||
The [[digamma function]] is the [[logarithmic derivative]] of the gamma function. Just as the gamma function provides a continuous interpolation of the factorials, offset by one, the digamma function provides a continuous interpolation of the [[harmonic number]]s, offset by the [[Euler–Mascheroni constant]].<ref>{{cite journal | last = Ross | first = Bertram | doi = 10.1080/0025570X.1978.11976704 | issue = 3 | journal = [[Mathematics Magazine]] | jstor = 2689999 | mr = 1572267 | pages = 176–179 | title = The psi function | volume = 51 | year = 1978}}</ref> | The [[digamma function]] is the [[logarithmic derivative]] of the gamma function. Just as the gamma function provides a continuous interpolation of the factorials, offset by one, the digamma function provides a continuous interpolation of the [[harmonic number]]s, offset by the [[Euler–Mascheroni constant]].<ref>{{cite journal | last = Ross | first = Bertram | doi = 10.1080/0025570X.1978.11976704 | issue = 3 | journal = [[Mathematics Magazine]] | jstor = 2689999 | mr = 1572267 | pages = 176–179 | title = The psi function | volume = 51 | year = 1978}}</ref> | ||
| Line 213: | Line 223: | ||
===Computation=== | ===Computation=== | ||
[[File:Vintage Texas Instruments Model SR-50A Handheld LED Electronic Calculator, Made in the USA, Price Was $109.50 in 1975 (8715012843).jpg|thumb|[[TI SR-50|TI SR-50A]], a 1975 calculator with a factorial key (third row, center right)]] | [[File:Vintage Texas Instruments Model SR-50A Handheld LED Electronic Calculator, Made in the USA, Price Was $109.50 in 1975 (8715012843).jpg|thumb|[[TI SR-50|TI SR-50A]], a 1975 calculator with a factorial key (third row, center right)]] | ||
The factorial function is a common feature in [[scientific calculator]]s.<ref>{{cite book|title=Understandable Statistics: Concepts and Methods|first1=Charles Henry|last1=Brase|first2=Corrinne Pellillo|last2=Brase|edition=11th|publisher=Cengage Learning|year=2014|isbn=978-1-305-14290-9|page=182|url=https://books.google.com/books?id=a8OiAgAAQBAJ&pg=PA182}}</ref> It is also included in scientific programming libraries such as the [[Python (programming language)|Python]] mathematical functions module<ref>{{cite web|url=https://docs.python.org/3/library/math.html|title=math — Mathematical functions|work=Python 3 Documentation: The Python Standard Library|access-date=2021-12-21}}</ref> and the [[Boost (C++ libraries)|Boost C++ library]].<ref>{{cite web|url=https://www.boost.org/doc/libs/1_78_0/libs/math/doc/html/math_toolkit/factorials/sf_factorial.html| title=Factorial|work=Boost 1.78.0 Documentation: Math Special Functions|access-date=2021-12-21 | The factorial function is a common feature in [[scientific calculator]]s.<ref>{{cite book|title=Understandable Statistics: Concepts and Methods|first1=Charles Henry|last1=Brase|first2=Corrinne Pellillo|last2=Brase|edition=11th|publisher=Cengage Learning|year=2014|isbn=978-1-305-14290-9|page=182|url=https://books.google.com/books?id=a8OiAgAAQBAJ&pg=PA182}}</ref> It is also included in scientific programming libraries such as the [[Python (programming language)|Python]] mathematical functions module<ref>{{cite web|url=https://docs.python.org/3/library/math.html|title=math — Mathematical functions|work=Python 3 Documentation: The Python Standard Library|access-date=2021-12-21}}</ref> and the [[Boost (C++ libraries)|Boost C++ library]].<ref>{{cite web|url=https://www.boost.org/doc/libs/1_78_0/libs/math/doc/html/math_toolkit/factorials/sf_factorial.html| title=Factorial|work=Boost 1.78.0 Documentation: Math Special Functions|access-date=2021-12-21}}</ref> | ||
The computation of <math>n!</math> can be expressed in [[pseudocode]] using [[iteration]]<ref>{{cite book|title=MATLAB Programming for Engineers|first=Stephen J.|last=Chapman|edition=6th|publisher=Cengage Learning|year=2019| isbn=978-0-357-03052-3| page=215|contribution=Example 5.2: The factorial function|contribution-url=https://books.google.com/books?id=jVEzEAAAQBAJ&pg=PA215}}</ref> as | If efficiency is not a concern, computing factorials is trivial: just successively multiply a variable initialized {{nowrap|to <math>1</math>}} by the integers up {{nowrap|to <math>n</math>.}} The simplicity of this computation makes it a common example in the use of different computer programming styles and methods.<ref>{{cite book|title=Drawing Programs: The Theory and Practice of Schematic Functional Programming|first1=Tom|last1=Addis|first2=Jan|last2=Addis|publisher=Springer| year=2009| isbn=978-1-84882-618-2| pages=149–150|url=https://books.google.com/books?id=cWM7ZBfEl_0C&pg=PA149}}</ref> The computation of <math>n!</math> can be expressed in [[pseudocode]] using [[iteration]]<ref>{{cite book|title=MATLAB Programming for Engineers|first=Stephen J.|last=Chapman|edition=6th|publisher=Cengage Learning|year=2019| isbn=978-0-357-03052-3| page=215|contribution=Example 5.2: The factorial function|contribution-url=https://books.google.com/books?id=jVEzEAAAQBAJ&pg=PA215}}</ref> as | ||
define factorial(''n''): | '''define''' factorial(''n''): | ||
''f'' := 1 | ''f'' := 1 | ||
for ''i'' := 1, 2, 3, ..., ''n'': | '''for''' ''i'' := 1, 2, 3, ..., ''n'': | ||
''f'' := ''f'' * ''i'' | ''f'' := ''f'' * ''i'' | ||
return ''f'' | '''return''' ''f'' | ||
or using [[Recursion (computer science)|recursion]]<ref>{{cite book|title=The Computing Universe: A Journey through a Revolution|first1=Tony|last1=Hey|first2=Gyuri|last2=Pápay|publisher=Cambridge University Press|year=2014|isbn=9781316123225|page=64|url=https://books.google.com/books?id=q4FIBQAAQBAJ&pg=PA64}}</ref> based on its recurrence relation as | or using [[Recursion (computer science)|recursion]]<ref>{{cite book|title=The Computing Universe: A Journey through a Revolution|first1=Tony|last1=Hey|first2=Gyuri|last2=Pápay|publisher=Cambridge University Press|year=2014|isbn=9781316123225|page=64|url=https://books.google.com/books?id=q4FIBQAAQBAJ&pg=PA64}}</ref> based on its recurrence relation as | ||
define factorial(''n''): | '''define''' factorial(''n''): | ||
if (''n'' = 0) return 1 | '''if''' (''n'' = 0) '''return''' 1 | ||
return ''n'' * factorial(''n'' − 1) | '''return''' ''n'' * factorial(''n'' − 1) | ||
Other methods suitable for its computation include [[memoization]],<ref>{{cite book|title=Hands-On Functional Programming with C++: An effective guide to writing accelerated functional code using C++17 and C++20| first=Alexandru|last=Bolboaca | publisher=Packt Publishing|year=2019|isbn=978-1-78980-921-3|page=188|url=https://books.google.com/books?id=GwSgDwAAQBAJ&pg=PA188}}</ref> [[dynamic programming]],<ref>{{cite book|title=Mastering Mathematica: Programming Methods and Applications| first=John W.|last=Gray|publisher=Academic Press|year=2014|isbn=978-1-4832-1403-0|pages=233–234| url=https://books.google.com/books?id=a4riBQAAQBAJ&pg=PA233}}</ref> and [[functional programming]].<ref>{{cite book|title=Scala From a Functional Programming Perspective: An Introduction to the Programming Language|volume=9980|series=Lecture Notes in Computer Science| first=Vicenç| last=Torra| publisher=Springer|year=2016|isbn=978-3-319-46481-7|page=96|url=https://books.google.com/books?id=eMwcDQAAQBAJ&pg=PA96}}</ref> The [[computational complexity]] of these algorithms may be analyzed using the unit-cost [[random-access machine]] model of computation, in which each arithmetic operation takes constant time and each number uses a constant amount of storage space. In this model, these methods can compute <math>n!</math> in time {{nowrap|<math>O(n)</math>,}} and the iterative version uses space {{nowrap|<math>O(1)</math>.}} Unless optimized for [[tail recursion]], the recursive version takes linear space to store its [[call stack]].<ref>{{cite book|title=Functional Programming and Its Applications: An Advanced Course| publisher=Cambridge University Press|series=CREST Advanced Courses|contribution=LISP, programming, and implementation| first=Gerald Jay|last=Sussman|author-link=Gerald Jay Sussman|year=1982|pages=29–72|isbn=978-0-521-24503-6}} See in particular [https://books.google.com/books?id=O_M8AAAAIAAJ&pg=PA34 p. 34].</ref> However, this model of computation is only suitable when <math>n</math> is small enough to allow <math>n!</math> to fit into a [[machine word]].<ref>{{cite journal | last = Chaudhuri | first = Ranjan | date = June 2003 | doi = 10.1145/782941.782977 | issue = 2 | journal = ACM SIGCSE Bulletin | pages = 43–44 | publisher = Association for Computing Machinery | title = Do the arithmetic operations really execute in constant time? | volume = 35| s2cid = 13629142 }}</ref> The values 12! and 20! are the largest factorials that can be stored in, respectively, the [[32-bit computing|32-bit]]<ref name=fateman/> and [[64-bit computing|64-bit]] [[Integer (computer science)|integers]].<ref name=sigplan>{{cite journal | last1 = Winkler | first1 = Jürgen F. H. | last2 = Kauer | first2 = Stefan | date = March 1997 | doi = 10.1145/251634.251638 | issue = 3 | journal = ACM SIGPLAN Notices | pages = 38–41 | publisher = Association for Computing Machinery | title = Proving assertions is also useful | volume = 32| s2cid = 17347501 | doi-access = free }}</ref> [[Floating point]] can represent larger factorials, but approximately rather than exactly, and will still overflow for factorials larger than {{nowrap|<math>170!</math>.<ref name=fateman>{{cite web| url=http://people.eecs.berkeley.edu/~fateman/papers/factorial.pdf|title=Comments on Factorial Programs|date=April 11, 2006| publisher=University of California, Berkeley|first=Richard J.|last=Fateman|author-link=Richard Fateman}}</ref>}} | Other methods suitable for its computation include [[memoization]],<ref>{{cite book|title=Hands-On Functional Programming with C++: An effective guide to writing accelerated functional code using C++17 and C++20| first=Alexandru|last=Bolboaca | publisher=Packt Publishing|year=2019|isbn=978-1-78980-921-3|page=188|url=https://books.google.com/books?id=GwSgDwAAQBAJ&pg=PA188}}</ref> [[dynamic programming]],<ref>{{cite book|title=Mastering Mathematica: Programming Methods and Applications| first=John W.|last=Gray|publisher=Academic Press|year=2014|isbn=978-1-4832-1403-0|pages=233–234| url=https://books.google.com/books?id=a4riBQAAQBAJ&pg=PA233}}</ref> and [[functional programming]].<ref>{{cite book|title=Scala From a Functional Programming Perspective: An Introduction to the Programming Language|volume=9980|series=Lecture Notes in Computer Science| first=Vicenç| last=Torra| publisher=Springer|year=2016|isbn=978-3-319-46481-7|page=96|url=https://books.google.com/books?id=eMwcDQAAQBAJ&pg=PA96}}</ref> The [[computational complexity]] of these algorithms may be analyzed using the unit-cost [[random-access machine]] model of computation, in which each arithmetic operation takes constant time and each number uses a constant amount of storage space. In this model, these methods can compute <math>n!</math> in time {{nowrap|<math>O(n)</math>,}} and the iterative version uses space {{nowrap|<math>O(1)</math>.}} Unless optimized for [[tail recursion]], the recursive version takes linear space to store its [[call stack]].<ref>{{cite book|title=Functional Programming and Its Applications: An Advanced Course| publisher=Cambridge University Press|series=CREST Advanced Courses|contribution=LISP, programming, and implementation| first=Gerald Jay|last=Sussman|author-link=Gerald Jay Sussman|year=1982|pages=29–72|isbn=978-0-521-24503-6}} See in particular [https://books.google.com/books?id=O_M8AAAAIAAJ&pg=PA34 p. 34].</ref> However, this model of computation is only suitable when <math>n</math> is small enough to allow <math>n!</math> to fit into a [[machine word]].<ref>{{cite journal | last = Chaudhuri | first = Ranjan | date = June 2003 | doi = 10.1145/782941.782977 | issue = 2 | journal = ACM SIGCSE Bulletin | pages = 43–44 | publisher = Association for Computing Machinery | title = Do the arithmetic operations really execute in constant time? | volume = 35| s2cid = 13629142 }}</ref> The values 12! and 20! are the largest factorials that can be stored in, respectively, the [[32-bit computing|32-bit]]<ref name=fateman/> and [[64-bit computing|64-bit]] [[Integer (computer science)|integers]].<ref name=sigplan>{{cite journal | last1 = Winkler | first1 = Jürgen F. H. | last2 = Kauer | first2 = Stefan | date = March 1997 | doi = 10.1145/251634.251638 | issue = 3 | journal = ACM SIGPLAN Notices | pages = 38–41 | publisher = Association for Computing Machinery | title = Proving assertions is also useful | volume = 32| s2cid = 17347501 | doi-access = free }}</ref> [[Floating point]] can represent larger factorials, but approximately rather than exactly, and will still overflow for factorials larger than {{nowrap|<math>170!</math>.<ref name=fateman>{{cite web| url=http://people.eecs.berkeley.edu/~fateman/papers/factorial.pdf|title=Comments on Factorial Programs|date=April 11, 2006| publisher=University of California, Berkeley|first=Richard J.|last=Fateman|author-link=Richard Fateman}}</ref>}} | ||
The exact computation of larger factorials involves [[arbitrary-precision arithmetic]], because of [[Factorial#Growth_and_approximation|fast growth]] and [[integer overflow]]. | The exact computation of larger factorials involves [[arbitrary-precision arithmetic]], because of [[Factorial#Growth_and_approximation|fast growth]] and [[integer overflow]]. Time of computation can be analyzed as a function of the number of digits or bits in the result.<ref name=sigplan/> By Stirling's formula, <math>n!</math> has <math>b = O(n\log n)</math> bits.<ref name=borwein/> The [[Schönhage–Strassen algorithm]] can produce a {{nowrap|<math>b</math>-bit}} product in time {{nowrap|<math>O(b\log b\log\log b)</math>,}} and faster [[multiplication algorithm]]s taking time <math>O(b\log b)</math> are known.<ref>{{cite journal | last1 = Harvey | first1 = David | last2 = van der Hoeven | first2 = Joris | author2-link = Joris van der Hoeven | doi = 10.4007/annals.2021.193.2.4 | issue = 2 | journal = [[Annals of Mathematics]] | mr = 4224716 | pages = 563–617 | series = Second Series | title = Integer multiplication in time <math>O(n \log n)</math>| volume = 193 | year = 2021| s2cid = 109934776 | url = https://hal.archives-ouvertes.fr/hal-02070778/file/nlogn.pdf }}</ref> However, computing the factorial involves repeated products, rather than a single multiplication, so these time bounds do not apply directly. In this setting, computing <math>n!</math> by multiplying the numbers from 1 {{nowrap|to <math>n</math>}} in sequence is inefficient, because it involves <math>n</math> multiplications, a constant fraction of which take time <math>O(n\log^2 n)</math> each, giving total time {{nowrap|<math>O(n^2\log^2 n)</math>.}} A better approach is to perform the multiplications as a [[divide-and-conquer algorithm]] that multiplies a sequence of <math>i</math> numbers by splitting it into two subsequences of <math>i/2</math> numbers, multiplies each subsequence, and combines the results with one last multiplication. This approach to the factorial takes total time {{nowrap|<math>O(n\log^3 n)</math>:}} one logarithm comes from the number of bits in the factorial, a second comes from the multiplication algorithm, and a third comes from the divide and conquer.<ref>{{cite book|last=Arndt|first=Jörg| title=Matters Computational: Ideas, Algorithms, Source Code|publisher=Springer|year=2011|url=http://jjj.de/fxt/fxtbook.pdf| contribution=34.1.1.1: Computation of the factorial|pages=651–652}} See also "34.1.5: Performance", pp. 655–656.</ref> | ||
Even better efficiency is obtained by computing {{math|''n''!}} from its prime factorization, based on the principle that [[exponentiation by squaring]] is faster than expanding an exponent into a product.<ref name=borwein>{{cite journal | last = Borwein | first = Peter B. | author-link = Peter Borwein | doi = 10.1016/0196-6774(85)90006-9 | issue = 3 | journal = [[Journal of Algorithms]] | mr = 800727 | pages = 376–380 | title = On the complexity of calculating factorials | volume = 6 | year = 1985}}</ref><ref name=schonhage>{{cite book|first=Arnold|last=Schönhage|year=1994|title=Fast algorithms: a multitape Turing machine implementation|publisher=B.I. Wissenschaftsverlag|page=226}}</ref> An algorithm for this by [[Arnold Schönhage]] begins by finding the list of the primes up {{nowrap|to <math>n</math>,}} for instance using the [[sieve of Eratosthenes]], and uses Legendre's formula to compute the exponent for each prime. Then it computes the product of the prime powers with these exponents, using a recursive algorithm, as follows: | Even better efficiency is obtained by computing {{math|''n''!}} from its prime factorization, based on the principle that [[exponentiation by squaring]] is faster than expanding an exponent into a product.<ref name=borwein>{{cite journal | last = Borwein | first = Peter B. | author-link = Peter Borwein | doi = 10.1016/0196-6774(85)90006-9 | issue = 3 | journal = [[Journal of Algorithms]] | mr = 800727 | pages = 376–380 | title = On the complexity of calculating factorials | volume = 6 | year = 1985}}</ref><ref name=schonhage>{{cite book|first=Arnold|last=Schönhage|year=1994|title=Fast algorithms: a multitape Turing machine implementation|publisher=B.I. Wissenschaftsverlag|page=226}}</ref> An algorithm for this by [[Arnold Schönhage]] begins by finding the list of the primes up {{nowrap|to <math>n</math>,}} for instance using the [[sieve of Eratosthenes]], and uses Legendre's formula to compute the exponent for each prime. Then it computes the product of the prime powers with these exponents, using a recursive algorithm, as follows: | ||
| Line 279: | Line 289: | ||
;Superfactorial | ;Superfactorial | ||
:The [[superfactorial]] of <math>n</math> is the product of the first <math>n</math> factorials. The superfactorials are continuously interpolated by the [[Barnes G-function]].<ref>{{cite journal|last=Barnes|first=E. W.|author-link=Ernest Barnes|jfm=30.0389.02|journal=[[The Quarterly Journal of Pure and Applied Mathematics]]|pages=264–314|title=The theory of the {{mvar|G}}-function|url=https://gdz.sub.uni-goettingen.de/id/PPN600494829_0031?tify={%22pages%22:[268],%22view%22:%22toc%22}|volume=31|year=1900}}</ref> | :The [[superfactorial]] of <math>n</math> is the product of the first <math>n</math> factorials. The superfactorials are continuously interpolated by the [[Barnes G-function]].<ref>{{cite journal|last=Barnes|first=E. W.|author-link=Ernest Barnes|jfm=30.0389.02|journal=[[The Quarterly Journal of Pure and Applied Mathematics]]|pages=264–314|title=The theory of the {{mvar|G}}-function|url=https://gdz.sub.uni-goettingen.de/id/PPN600494829_0031?tify={%22pages%22:[268],%22view%22:%22toc%22}|volume=31|year=1900}}</ref> | ||
;Triangular number | |||
:Just as the <math>n</math>th factorial is the product of the first <math>n</math> positive integers, the <math>n</math>th [[triangular number]] is the sum of the first <math>n</math> positive integers. [[Donald Knuth]] has proposed the name ''termial'' and the notation <math>n?</math> for the triangular numbers, making the analogy to factorials more explicit, but these are not in wide use.<ref>{{TAOCP|volume=1|edition=3|pages=48}}</ref> | |||
==References== | ==References== | ||
Latest revision as of 02:08, 31 May 2026
| Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} | Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n!} |
|---|---|
| 0 | 1 |
| 1 | 1 |
| 2 | 2 |
| 3 | 6 |
| 4 | 24 |
| 5 | 120 |
| 6 | 720 |
| 7 | 5040 |
| 8 | 40320 |
| 9 | 362880 |
| 10 | 3628800 |
| 11 | 39916800 |
| 12 | 479001600 |
| 13 | 6227020800 |
| 14 | 87178291200 |
| 15 | 1307674368000 |
| 16 | 20922789888000 |
| 17 | 355687428096000 |
| 18 | 6402373705728000 |
| 19 | 121645100408832000 |
| 20 | 2432902008176640000 |
| 25 | 1.551121004×1025 |
| 50 | 3.041409320×1064 |
| 52 | 8.065817517×1067 |
| 70 | 1.197857167×10100 |
| 100 | 9.332621544×10157 |
| 450 | 1.733368733×101000 |
| 1000 | 4.023872601×102567 |
| 3249 | 6.412337688×1010000 |
| 10000 | 2.846259681×1035659 |
| 25206 | 1.205703438×10100000 |
| 100000 | 2.824229408×10456573 |
| 205023 | 2.503898932×101000004 |
| 1000000 = 106 |
8.263931688×105565708 ≈ 105.5657089172×106 |
| 1010 | 109.5657055186×1010 |
| 1020 | 1019.5657055181×1020 |
| 1050 | 1049.5657055181×1050 |
| 10100 | 1099.5657055181×10100 |
| 101000 | 10999.5657055181×101000 |
In mathematics, the factorial of a non-negative integer Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} , denoted by Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n!} , is the product of all positive integers less than or equal to Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} . The factorial of Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} also equals the product of Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} with the next smaller factorial: Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \begin{align} n! &= n \times (n-1) \times (n-2) \times (n-3) \times \cdots \times 3 \times 2 \times 1 \\ &= \begin{cases} 1, & \text{if } n = 0 \\ n \times (n-1)!, & \text{if } n \ge 1. \end{cases}\\ \end{align}} For example, Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle 5! = 5\times 4! = 5 \times 4 \times 3 \times 2 \times 1 = 120.} The value of 0! is 1, according to the convention for an empty product.[1]
Factorials have been discovered in several ancient cultures, notably in Indian mathematics in the canonical works of Jain literature, and by Jewish mystics in the Talmudic book Sefer Yetzirah. The factorial operation is encountered in many areas of mathematics, notably in combinatorics, where its most basic use counts the possible distinct sequences – the permutations – of Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} distinct objects: there are Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n!} . In mathematical analysis, factorials are used in power series for the exponential function and other functions, and they also have applications in algebra, number theory, probability theory, and computer science.
Much of the mathematics of the factorial function was developed beginning in the late 18th and early 19th centuries. Stirling's approximation provides an accurate approximation to the factorial of large numbers, showing that it grows more quickly than exponential growth. Legendre's formula describes the exponents of the prime numbers in a prime factorization of the factorials, and can be used to count the trailing zeros of the factorials. Daniel Bernoulli and Leonhard Euler interpolated the factorial function to a continuous function of complex numbers, except at the negative integers, the (offset) gamma function.
Many other notable functions and number sequences are closely related to the factorials, including the binomial coefficients, double factorials, falling factorials, primorials, and subfactorials. Implementations of the factorial function are commonly used as an example of different computer programming styles, and are included in scientific calculators and scientific computing software libraries. Although directly computing large factorials using the product formula or recurrence is not efficient, faster algorithms are known, matching to within a constant factor the time for fast multiplication algorithms for numbers with the same number of digits.
History
The concept of factorials has arisen independently in many cultures:
- In Indian mathematics, one of the earliest known descriptions of factorials comes from the Anuyogadvāra-sūtra,[2] one of the canonical works of Jain literature, which has been assigned dates varying from 300 BCE to 400 CE.[3] It separates out the sorted and reversed order of a set of items from the other ("mixed") orders, evaluating the number of mixed orders by subtracting two from the usual product formula for the factorial. The product rule for permutations was also described by 6th-century CE Jain monk Jinabhadra.[2] Hindu scholars have been using factorial formulas since at least 1150, when Bhāskara II mentioned factorials in his work Līlāvatī, in connection with a problem of how many ways Vishnu could hold his four characteristic objects (a conch shell, discus, mace, and lotus flower) in his four hands, and a similar problem for a ten-handed god.[4]
- In the mathematics of the Middle East, the Hebrew mystic book of creation Sefer Yetzirah, from the Talmudic period (200 to 500 CE), lists factorials up to 7! as part of an investigation into the number of words that can be formed from the Hebrew alphabet.[5][6] Factorials were also studied for similar reasons by 8th-century Arab grammarian Al-Khalil ibn Ahmad al-Farahidi.[5] Arab mathematician Ibn al-Haytham (also known as Alhazen, c. 965 – c. 1040) was the first to formulate Wilson's theorem connecting the factorials with the prime numbers.[7]
- In Europe, although Greek mathematics included some combinatorics, and Plato famously used 5,040 (a factorial) as the population of an ideal community, in part because of its divisibility properties,[8] there is no direct evidence of ancient Greek study of factorials. Instead, the first work on factorials in Europe was by Jewish scholars such as Shabbethai Donnolo, explicating the Sefer Yetzirah passage.[9] In 1677, British author Fabian Stedman described the application of factorials to change ringing, a musical art involving the ringing of several tuned bells.[10][11]
From the late 15th century onward, factorials became the subject of study by Western mathematicians. In a 1494 treatise, Italian mathematician Luca Pacioli calculated factorials up to 11!, in connection with a problem of dining table arrangements.[12] Christopher Clavius discussed factorials in a 1603 commentary on the work of Johannes de Sacrobosco, and in the 1640s, French polymath Marin Mersenne published large (but not entirely correct) tables of factorials, up to 64!, based on the work of Clavius.[13] The power series for the exponential function, with the reciprocals of factorials for its coefficients, was first formulated in 1676 by Isaac Newton in a letter to Gottfried Wilhelm Leibniz.[14] Other important works of early European mathematics on factorials include extensive coverage in a 1685 treatise by John Wallis, a study of their approximate values for large values of Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} by Abraham de Moivre in 1721, a 1729 letter from James Stirling to de Moivre stating what became known as Stirling's approximation, and work at the same time by Daniel Bernoulli and Leonhard Euler formulating the continuous extension of the factorial function to the gamma function.[15] Adrien-Marie Legendre included Legendre's formula, describing the exponents in the factorization of factorials into prime powers, in an 1808 text on number theory.[16]
The notation Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n!} for factorials was introduced by the French mathematician Christian Kramp in 1808.[17] Many other notations have also been used. Another later notation Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \vert\!\underline{\,n}} , in which the argument of the factorial was half-enclosed by the left and bottom sides of a box, was popular for some time in Britain and America but fell out of use, perhaps because it is difficult to typeset.[17] The word "factorial" (originally French: factorielle) was first used in 1800 by Louis François Antoine Arbogast,[18] in the first work on Faà di Bruno's formula,[19] but referring to a more general concept of products of arithmetic progressions. The "factors" that this name refers to are the terms of the product formula for the factorial.[20]
Definition
The factorial function of a positive integer Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} is defined by the product of all positive integers not greater than Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} [1] Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n! = 1 \cdot 2 \cdot 3 \cdots (n-2) \cdot (n-1) \cdot n.} This may be written more concisely in product notation as[1] Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n! = \prod_{i = 1}^n i.}
If this product formula is changed to keep all but the last term, it would define a product of the same form, for a smaller factorial. This leads to a recurrence relation, according to which each value of the factorial function can be obtained by multiplying the previous value by Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} :[21] Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n! = n\cdot (n-1)!.} For example, Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle 5! = 5\cdot 4!=5\cdot 24=120} .
Factorial of zero
The factorial of Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle 0} is Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle 1} , or in symbols, Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle 0!=1} . There are several motivations for this definition:
- For Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n=0} , the definition of Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n!} as a product involves the product of no numbers at all, and so is an example of the broader convention that the empty product, a product of no factors, is equal to the multiplicative identity.[22]
- There is exactly one permutation of zero objects: with nothing to permute, the only rearrangement is to do nothing.[21]
- This convention makes many identities in combinatorics valid for all valid choices of their parameters. For instance, the number of ways to choose all Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} elements from a set of Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} is Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\textstyle \tbinom{n}{n} = \tfrac{n!}{n!0!} = 1,} a binomial coefficient identity that would only be valid with Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle 0!=1} .[23]
- With Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle 0!=1} , the recurrence relation for the factorial remains valid at Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n=1} . Therefore, with this convention, a recursive computation of the factorial needs to have only the value for zero as a base case, simplifying the computation and avoiding the need for additional special cases.[24]
- Setting Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle 0!=1} allows for the compact expression of many formulae, such as the exponential function, as a power series: Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\textstyle e^x = \sum_{n = 0}^\infty \frac{x^n}{n!}.} [14]
- This choice matches the gamma function Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle 0! = \Gamma(0+1) = 1} , and the gamma function is defined as a continuous function of complex numbers that does not involve a separate choice at this value.[25]
Applications
The earliest uses of the factorial function involve counting permutations: there are Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n!} different ways of arranging Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} distinct objects into a sequence.[26] Factorials appear more broadly in many formulas in combinatorics, to account for different orderings of objects. For instance the binomial coefficients Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \tbinom{n}{k}} count the Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle k} -element combinations (subsets of Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle k} elements) from a set with Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} elements, and can be computed from factorials using the formula[27] Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \binom{n}{k}=\frac{n!}{k!(n-k)!}.} The Stirling numbers of the first kind sum to the factorials, and count the permutations of Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} grouped into subsets with the same numbers of cycles.[28] Another combinatorial application is in counting derangements, permutations that do not leave any element in its original position; the number of derangements of Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} items is the nearest integer to Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n!/e} .[29]
In algebra, the factorials arise through the binomial theorem, which uses binomial coefficients to expand powers of sums.[30] They also occur in the coefficients used to relate certain families of polynomials to each other, for instance in Newton's identities for symmetric polynomials.[31] Their use in counting permutations can also be restated algebraically: the factorials are the orders of finite symmetric groups.[32] In calculus, factorials occur in Faà di Bruno's formula for chaining higher derivatives.[19] In mathematical analysis, factorials frequently appear in the denominators of power series, most notably in the series for the exponential function,[14] Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle e^x=1+\frac{x}{1}+\frac{x^2}{2}+\frac{x^3}{6}+\cdots = \sum_{k=0}^{\infty}\frac{x^k}{k!},} and in the coefficients of other Taylor series (in particular those of the trigonometric and hyperbolic functions), where they cancel factors of Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n!} coming from the Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} th derivative of Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle x^n} .[33] This usage of factorials in power series connects back to analytic combinatorics through the exponential generating function, which for a combinatorial class with Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n_i} elements of size Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle i} is defined as the power series[34] Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \sum_{k=0}^{\infty} \frac{x^k n_k}{k!}.}
In number theory, the most salient property of factorials is the divisibility of Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n!} by all positive integers up to Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} , described more precisely for prime factors by Legendre's formula. It follows that arbitrarily large prime numbers can be found as the prime factors of the numbers Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n!\pm 1} , leading to a proof of Euclid's theorem that the number of primes is infinite.[35] When Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n!\pm 1} is itself prime it is called a factorial prime;[36] relatedly, Brocard's problem, also posed by Srinivasa Ramanujan, concerns the existence of square numbers of the form Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n!+1} .[37] In contrast, the numbers Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n!+2,n!+3,\dots n!+n} must all be composite, proving the existence of arbitrarily large prime gaps.[38] An elementary proof of Bertrand's postulate on the existence of a prime in any interval of the form Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle [n,2n]} , one of the first results of Paul Erdős, was based on the divisibility properties of factorials.[39][40] The factorial number system is a mixed radix notation for numbers in which the place values of each digit are factorials.[41]
Factorials are used extensively in probability theory, for instance in the Poisson distribution[42] and in the probabilities of random permutations.[43] In computer science, beyond appearing in the analysis of brute-force searches over permutations,[44] factorials arise in the lower bound of Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \log_2 n!=n\log_2n-O(n)} on the number of comparisons needed to comparison sort a set of Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} items,[45] and in the analysis of chained hash tables, where the distribution of keys per cell can be accurately approximated by a Poisson distribution.[46] Moreover, factorials naturally appear in formulae from quantum and statistical physics, where one often considers all the possible permutations of a set of particles. In statistical mechanics, calculations of entropy such as Boltzmann's entropy formula or the Sackur–Tetrode equation must correct the count of microstates by dividing by the factorials of the numbers of each type of indistinguishable particle to avoid the Gibbs paradox. Quantum physics provides the underlying reason for why these corrections are necessary.[47]
Properties
Growth and approximation
As a function of Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} , the factorial has faster than exponential growth, but grows more slowly than a double exponential function.[48] Its growth rate is similar to Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n^n} , but slower by an exponential factor. One way of approaching this result is by taking the natural logarithm of the factorial, which turns its product formula into a sum, and then estimating the sum by an integral: Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \ln n! = \sum_{x=1}^n \ln x \approx \int_1^n\ln x\, dx=n\ln n-n+1.} Exponentiating the result (and ignoring the negligible Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle +1} term) approximates Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n!} as Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle (n/e)^n} .[49] More carefully bounding the sum both above and below by an integral, using the trapezoid rule, shows that this estimate needs a correction factor proportional to Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \sqrt n} . The constant of proportionality for this correction can be found from the Wallis product, which expresses Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \pi} as a limiting ratio of factorials and powers of two. The result of these corrections is Stirling's approximation:[50] Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n!\sim\sqrt{2\pi n}\left(\frac{n}{e}\right)^n\,.} Here, the Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \sim} symbol means that, as Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} goes to infinity, the ratio between the left and right sides approaches Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle 1} in the limit. Stirling's formula provides the first term in an asymptotic series that becomes even more accurate when taken to greater numbers of terms:[51] Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n! \sim \sqrt{2\pi n}\left(\frac{n}{e}\right)^n \left(1 +\frac{1}{12n}+\frac{1}{288n^2} - \frac{139}{51840n^3} -\frac{571}{2488320n^4}+ \cdots \right).} An alternative version (the approximation derived directly from the Euler–Maclaurin formula) converges faster because it only requires odd exponents in the correction terms:[51] Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n! \sim \sqrt{2\pi n}\left(\frac{n}{e}\right)^n \exp\left(\frac{1}{12n} - \frac{1}{360n^3} + \frac{1}{1260n^5} -\frac{1}{1680n^7}+ \cdots \right).} Many other variations of these formulas have also been developed, by Srinivasa Ramanujan, Bill Gosper, and others.[51]
The binary logarithm of the factorial, used to analyze comparison sorting, can be very accurately estimated using Stirling's approximation. In the formula below, the Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle O(1)} term invokes big O notation.[45] Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \log_2 n! = n\log_2 n- n \log_2 e + \frac12\log_2 n + O(1).}
Divisibility and digits
The product formula for the factorial implies that Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n!} is divisible by all prime numbers that are at most Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} , and by no larger prime numbers.[52] More precise information about its divisibility is given by Legendre's formula, which gives the exponent of each prime Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle p} in the prime factorization of Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n!} as[53][54] Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \sum_{i=1}^\infty \left \lfloor \frac n {p^i} \right \rfloor=\frac{n - s_p(n)}{p - 1}.} Here Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle s_p(n)} denotes the sum of the base-Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle p} digits of Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} . The exponent given by this formula can more technically be called the p-adic valuation of the factorial.[54] Applying Legendre's formula to the product formula for binomial coefficients produces Kummer's theorem, a similar result on the exponent of each prime in the factorization of a binomial coefficient.[55] Grouping the prime factors of the factorial into prime powers in different ways produces the multiplicative partitions of factorials.[56]
The special case of Legendre's formula for Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle p=5} gives the number of trailing zeros in the decimal representation of the factorials.[57] According to this formula, the number of zeros can be obtained by subtracting the base-5 digits of Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} from Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} , and dividing the result by four.[58] Legendre's formula implies that the exponent of the prime Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle p=2} is always larger than the exponent for Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle p=5} , so each factor of five can be paired with a factor of two to produce one of these trailing zeros.[57] The leading digits of the factorials are distributed according to Benford's law.[59] Every sequence of digits, in any base, is the sequence of initial digits of some factorial number in that base.[60]
Another result on divisibility of factorials, Wilson's theorem, states that Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle (n-1)!+1} is divisible by Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} if and only if Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} is a prime number.[52] For any given integer Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle x} , the Kempner function of Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle x} is given by the smallest Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} for which Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle x} divides Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n!} .[61] For almost all numbers (all but a subset of exceptions with asymptotic density zero), it coincides with the largest prime factor of Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle x} .[62]
The product of two factorials, Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle m!\cdot n!} , always evenly divides Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle (m+n)!} .[63] There are infinitely many factorials that equal the product of other factorials: if Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} is itself any product of factorials, then Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n!} equals that same product multiplied by one more factorial, Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle (n-1)!} . The only known examples of factorials that are products of other factorials but are not of this "trivial" form are Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle 9!=7!\cdot 3!\cdot 3!\cdot 2!} , Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle 10!=7!\cdot 6!=7!\cdot 5!\cdot 3!} , and Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle 16!=14!\cdot 5!\cdot 2!} .[64] It would follow from the abc conjecture that there are only finitely many nontrivial examples.[65]
The greatest common divisor of the values of a primitive polynomial of degree Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle d} over the integers evenly divides Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle d!} .[63]
Continuous interpolation and non-integer generalization
There are infinitely many ways to extend the factorials to a continuous function.[66] The most widely used of these[67] uses the gamma function, which can be defined for positive real numbers as the integral Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \Gamma(z) = \int_0^\infty x^{z-1} e^{-x}\,dx.} The resulting function is related to the factorial of a non-negative integer Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} by the equation Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n!=\Gamma(n+1),} which can be used as a definition of the factorial for non-integer arguments. At all values Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle x} for which both Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \Gamma(x)} and Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \Gamma(x-1)} are defined, the gamma function obeys the functional equation Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \Gamma(n)=(n-1)\Gamma(n-1),} generalizing the recurrence relation for the factorials.[66]
The same integral converges more generally for any complex number Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle z} whose real part is positive. It can be extended to the non-integer points in the rest of the complex plane by solving for Euler's reflection formula Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \Gamma(z)\Gamma(1-z)=\frac{\pi}{\sin\pi z}.} However, this formula cannot be used at integers because, for them, the Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \sin\pi z} term would produce a division by zero. The result of this extension process is an analytic function (more specifically a meromorphic function), the analytic continuation of the integral formula for the gamma function. It has a nonzero value at all complex numbers, except for the non-positive integers where it has simple poles. Correspondingly, this provides a definition for the factorial at all complex numbers other than the negative integers.[67] One property of the gamma function, distinguishing it from other continuous interpolations of the factorials, is given by the Bohr–Mollerup theorem, which states that the gamma function (offset by one) is the only log-convex function on the positive real numbers that interpolates the factorials and obeys the same functional equation. A related uniqueness theorem of Helmut Wielandt states that the complex gamma function and its scalar multiples are the only holomorphic functions on the positive complex half-plane that obey the functional equation and remain bounded for complex numbers with real part between 1 and 2.[68]
Other complex functions that interpolate the factorial values include Hadamard's gamma function, which is an entire function over all the complex numbers, including the non-positive integers.[69][70] In the p-adic numbers, it is not possible to continuously interpolate the factorial function directly, because the factorials of large integers (a dense subset of the p-adic integers) converge to zero according to Legendre's formula, forcing any continuous function that is close to their values to be zero everywhere. Instead, the p-adic gamma function provides a continuous interpolation of a modified form of the factorial, omitting the factors in the factorial that are divisible by p.[71]
The digamma function is the logarithmic derivative of the gamma function. Just as the gamma function provides a continuous interpolation of the factorials, offset by one, the digamma function provides a continuous interpolation of the harmonic numbers, offset by the Euler–Mascheroni constant.[72]
Computation
The factorial function is a common feature in scientific calculators.[73] It is also included in scientific programming libraries such as the Python mathematical functions module[74] and the Boost C++ library.[75]
If efficiency is not a concern, computing factorials is trivial: just successively multiply a variable initialized to Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle 1} by the integers up to Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} . The simplicity of this computation makes it a common example in the use of different computer programming styles and methods.[76] The computation of Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n!} can be expressed in pseudocode using iteration[77] as
define factorial(n):
f := 1
for i := 1, 2, 3, ..., n:
f := f * i
return f
or using recursion[78] based on its recurrence relation as
define factorial(n): if (n = 0) return 1 return n * factorial(n − 1)
Other methods suitable for its computation include memoization,[79] dynamic programming,[80] and functional programming.[81] The computational complexity of these algorithms may be analyzed using the unit-cost random-access machine model of computation, in which each arithmetic operation takes constant time and each number uses a constant amount of storage space. In this model, these methods can compute Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n!} in time Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle O(n)} , and the iterative version uses space Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle O(1)} . Unless optimized for tail recursion, the recursive version takes linear space to store its call stack.[82] However, this model of computation is only suitable when Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} is small enough to allow Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n!} to fit into a machine word.[83] The values 12! and 20! are the largest factorials that can be stored in, respectively, the 32-bit[84] and 64-bit integers.[85] Floating point can represent larger factorials, but approximately rather than exactly, and will still overflow for factorials larger than Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle 170!} .[84]
The exact computation of larger factorials involves arbitrary-precision arithmetic, because of fast growth and integer overflow. Time of computation can be analyzed as a function of the number of digits or bits in the result.[85] By Stirling's formula, Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n!} has Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle b = O(n\log n)} bits.[86] The Schönhage–Strassen algorithm can produce a Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle b} -bit product in time Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle O(b\log b\log\log b)} , and faster multiplication algorithms taking time Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle O(b\log b)} are known.[87] However, computing the factorial involves repeated products, rather than a single multiplication, so these time bounds do not apply directly. In this setting, computing Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n!} by multiplying the numbers from 1 to Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} in sequence is inefficient, because it involves Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} multiplications, a constant fraction of which take time Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle O(n\log^2 n)} each, giving total time Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle O(n^2\log^2 n)} . A better approach is to perform the multiplications as a divide-and-conquer algorithm that multiplies a sequence of Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle i} numbers by splitting it into two subsequences of Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle i/2} numbers, multiplies each subsequence, and combines the results with one last multiplication. This approach to the factorial takes total time Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle O(n\log^3 n)} : one logarithm comes from the number of bits in the factorial, a second comes from the multiplication algorithm, and a third comes from the divide and conquer.[88]
Even better efficiency is obtained by computing n! from its prime factorization, based on the principle that exponentiation by squaring is faster than expanding an exponent into a product.[86][89] An algorithm for this by Arnold Schönhage begins by finding the list of the primes up to Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} , for instance using the sieve of Eratosthenes, and uses Legendre's formula to compute the exponent for each prime. Then it computes the product of the prime powers with these exponents, using a recursive algorithm, as follows:
- Use divide and conquer to compute the product of the primes whose exponents are odd
- Divide all of the exponents by two (rounding down to an integer), recursively compute the product of the prime powers with these smaller exponents, and square the result
- Multiply together the results of the two previous steps
The product of all primes up to Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} is an Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle O(n)} -bit number, by the prime number theorem, so the time for the first step is Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle O(n\log^2 n)} , with one logarithm coming from the divide and conquer and another coming from the multiplication algorithm. In the recursive calls to the algorithm, the prime number theorem can again be invoked to prove that the numbers of bits in the corresponding products decrease by a constant factor at each level of recursion, so the total time for these steps at all levels of recursion adds in a geometric series to Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle O(n\log^2 n)} . The time for the squaring in the second step and the multiplication in the third step are again Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle O(n\log^2 n)} , because each is a single multiplication of a number with Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle O(n\log n)} bits. Again, at each level of recursion the numbers involved have a constant fraction as many bits (because otherwise repeatedly squaring them would produce too large a final result) so again the amounts of time for these steps in the recursive calls add in a geometric series to Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle O(n\log^2 n)} . Consequentially, the whole algorithm takes time Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle O(n\log^2 n)} , proportional to a single multiplication with the same number of bits in its result.[89]
Related sequences and functions
Several other integer sequences are similar to or related to the factorials:
- Alternating factorial
- The alternating factorial is the absolute value of the alternating sum of the first Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} factorials, Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\textstyle \sum_{i = 1}^n (-1)^{n - i}i!} . These have mainly been studied in connection with their primality; only finitely many of them can be prime, but a complete list of primes of this form is not known.[90]
- Bhargava factorial
- The Bhargava factorials are a family of integer sequences defined by Manjul Bhargava with similar number-theoretic properties to the factorials, including the factorials themselves as a special case.[63]
- Double factorial
- The product of all the odd integers up to some odd positive integer Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} is called the double factorial of Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} , and denoted by Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n!!} .[91] That is, Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle (2k-1)!! = \prod_{i=1}^k (2i-1) = \frac{(2k)!}{2^k k!}.} For example, 9!! = 1 × 3 × 5 × 7 × 9 = 945. Double factorials are used in trigonometric integrals,[92] in expressions for the gamma function at half-integers and the volumes of hyperspheres,[93] and in counting binary trees and perfect matchings.[91][94]
- Exponential factorial
- Just as triangular numbers sum the numbers from Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle 1} to Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} , and factorials take their product, the exponential factorial exponentiates. The exponential factorial is defined recursively as Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle a_0 = 1,\ a_n = n^{a_{n - 1}}} . For example, the exponential factorial of 4 is Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle 4^{3^{2^{1}}}=262144.} These numbers grow much more quickly than regular factorials.[95]
- Falling factorial
- The notations Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle (x)_{n}} or Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle x^{\underline n}} are sometimes used to represent the product of the greatest Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} integers counting up to and including Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle x} , equal to Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle x!/(x-n)!} . This is also known as a falling factorial or backward factorial, and the Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle (x)_{n}} notation is a Pochhammer symbol.[96] Falling factorials count the number of different sequences of Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} distinct items that can be drawn from a universe of Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle x} items.[97] They occur as coefficients in the higher derivatives of polynomials,[98] and in the factorial moments of random variables.[99]
- Hyperfactorials
- The hyperfactorial of Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} is the product Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle 1^1\cdot 2^2\cdots n^n} . These numbers form the discriminants of Hermite polynomials.[100] They can be continuously interpolated by the K-function,[101] and obey analogues to Stirling's formula[102] and Wilson's theorem.[103]
- Jordan–Pólya numbers
- The Jordan–Pólya numbers are the products of factorials, allowing repetitions. Every tree has a symmetry group whose number of symmetries is a Jordan–Pólya number, and every Jordan–Pólya number counts the symmetries of some tree.[104]
- Primorial
- The primorial Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n\#} is the product of prime numbers less than or equal to Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} ; this construction gives them some similar divisibility properties to factorials,[36] but unlike factorials they are squarefree.[105] As with the factorial primes Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n!\pm 1} , researchers have studied primorial primes Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n\#\pm 1} .[36]
- Subfactorial
- The subfactorial yields the number of derangements of a set of Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} objects. It is sometimes denoted Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle !n} , and equals the closest integer to Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n!/e} .[29]
- Superfactorial
- The superfactorial of Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} is the product of the first Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} factorials. The superfactorials are continuously interpolated by the Barnes G-function.[106]
- Triangular number
- Just as the Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} th factorial is the product of the first Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} positive integers, the Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} th triangular number is the sum of the first Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} positive integers. Donald Knuth has proposed the name termial and the notation Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n?} for the triangular numbers, making the analogy to factorials more explicit, but these are not in wide use.[107]
References
- ↑ 1.0 1.1 1.2 Graham, Ronald L.; Knuth, Donald E.; Patashnik, Oren (1988). Concrete Mathematics. Reading, MA: Addison-Wesley. p. 111. ISBN 0-201-14236-8.
- ↑ 2.0 2.1 Datta, Bibhutibhusan; Singh, Awadhesh Narayan (2019). "Use of permutations and combinations in India". In Kolachana, Aditya; Mahesh, K.; Ramasubramanian, K. (eds.). Studies in Indian Mathematics and Astronomy: Selected Articles of Kripa Shankar Shukla. Sources and Studies in the History of Mathematics and Physical Sciences. Springer Singapore. pp. 356–376. doi:10.1007/978-981-13-7326-8_18. ISBN 978-981-13-7325-1. S2CID 191141516.. Revised by K. S. Shukla from a paper in Indian Journal of History of Science 27 (3): 231–249, 1992, Template:MR. See p. 363.
- ↑ Jadhav, Dipak (August 2021). "Jaina Thoughts on Unity Not Being a Number". History of Science in South Asia. University of Alberta Libraries. 9: 209–231. doi:10.18732/hssa67. S2CID 238656716.. See discussion of dating on p. 211.
- ↑ Biggs, Norman L. (May 1979). "The roots of combinatorics". Historia Mathematica. 6 (2): 109–136. doi:10.1016/0315-0860(79)90074-0. MR 0530622.
- ↑ 5.0 5.1 Katz, Victor J. (June 1994). "Ethnomathematics in the classroom". For the Learning of Mathematics. 14 (2): 26–30. JSTOR 40248112.
- ↑ Sefer Yetzirah at Wikisource, Chapter IV, Section 4
- ↑ Rashed, Roshdi (1980). "Ibn al-Haytham et le théorème de Wilson". Archive for History of Exact Sciences (in French). 22 (4): 305–321. doi:10.1007/BF00717654. MR 0595903. S2CID 120885025.
- ↑ Acerbi, F. (2003). "On the shoulders of Hipparchus: a reappraisal of ancient Greek combinatorics". Archive for History of Exact Sciences. 57 (6): 465–502. doi:10.1007/s00407-003-0067-0. JSTOR 41134173. MR 2004966. S2CID 122758966.
- ↑ Katz, Victor J. (2013). "Chapter 4: Jewish combinatorics". In Wilson, Robin; Watkins, John J. (eds.). Combinatorics: Ancient & Modern. Oxford University Press. pp. 109–121. ISBN 978-0-19-965659-2. See p. 111.
- ↑ Hunt, Katherine (May 2018). "The Art of Changes: Bell-Ringing, Anagrams, and the Culture of Combination in Seventeenth-Century England" (PDF). Journal of Medieval and Early Modern Studies. 48 (2): 387–412. doi:10.1215/10829636-4403136.
- ↑ Stedman, Fabian (1677). Campanalogia. London. pp. 6–9. The publisher is given as "W.S." who may have been William Smith, possibly acting as agent for the Society of College Youths, to which society the "Dedicatory" is addressed.
- ↑ Knobloch, Eberhard (2013). "Chapter 5: Renaissance combinatorics". In Wilson, Robin; Watkins, John J. (eds.). Combinatorics: Ancient & Modern. Oxford University Press. pp. 123–145. ISBN 978-0-19-965659-2. See p. 126.
- ↑ Knobloch 2013, pp. 130–133.
- ↑ 14.0 14.1 14.2 Ebbinghaus, H.-D.; Hermes, H.; Hirzebruch, F.; Koecher, M.; Mainzer, K.; Neukirch, J.; Prestel, A.; Remmert, R. (1990). Numbers. Graduate Texts in Mathematics. 123. New York: Springer-Verlag. p. 131. doi:10.1007/978-1-4612-1005-4. ISBN 0-387-97202-1. MR 1066206.
- ↑ Dutka, Jacques (1991). "The early history of the factorial function". Archive for History of Exact Sciences. 43 (3): 225–249. doi:10.1007/BF00389433. JSTOR 41133918. MR 1171521. S2CID 122237769.
- ↑ Dickson, Leonard E. (1919). "Chapter IX: Divisibility of factorials and multinomial coefficients". History of the Theory of Numbers. 1. Carnegie Institution of Washington. pp. 263–278. See in particular p. 263.
- ↑ 17.0 17.1 Cajori, Florian (1929). "448–449. Factorial "n"". A History of Mathematical Notations, Volume II: Notations Mainly in Higher Mathematics. The Open Court Publishing Company. pp. 71–77.
- ↑ Miller, Jeff. "Earliest Known Uses of Some of the Words of Mathematics (F)". MacTutor History of Mathematics archive. University of St Andrews.
- ↑ 19.0 19.1 Craik, Alex D. D. (2005). "Prehistory of Faà di Bruno's formula". The American Mathematical Monthly. 112 (2): 119–130. doi:10.1080/00029890.2005.11920176. JSTOR 30037410. MR 2121322. S2CID 45380805.
- ↑ Arbogast, Louis François Antoine (1800). Du calcul des dérivations (in French). Strasbourg: L'imprimerie de Levrault, frères. pp. 364–365.
- ↑ 21.0 21.1 Hamkins, Joel David (2020). Proof and the Art of Mathematics. Cambridge, Massachusetts: MIT Press. p. 50. ISBN 978-0-262-53979-1. MR 4205951.
- ↑ Dorf, Richard C. (2003). "Factorials". CRC Handbook of Engineering Tables. CRC Press. p. 5-5. ISBN 978-0-203-00922-2.
- ↑ Goldenberg, E. Paul; Carter, Cynthia J. (October 2017). "A student asks about (−5)!". The Mathematics Teacher. 111 (2): 104–110. doi:10.5951/mathteacher.111.2.0104. JSTOR 10.5951/mathteacher.111.2.0104.
- ↑ Haberman, Bruria; Averbuch, Haim (2002). "The case of base cases: Why are they so difficult to recognize? Student difficulties with recursion". In Caspersen, Michael E.; Joyce, Daniel T.; Goelman, Don; Utting, Ian (eds.). Proceedings of the 7th Annual SIGCSE Conference on Innovation and Technology in Computer Science Education, ITiCSE 2002, Aarhus, Denmark, June 24-28, 2002. Association for Computing Machinery. pp. 84–88. doi:10.1145/544414.544441.
- ↑ Farrell, Orin J.; Ross, Bertram (1971). Solved Problems in Analysis: As Applied to Gamma, Beta, Legendre and Bessel Functions. Dover Books on Mathematics. Courier Corporation. p. 10. ISBN 978-0-486-78308-6.
- ↑ Conway, John H.; Guy, Richard (1998). "Factorial numbers". The Book of Numbers. Springer Science & Business Media. pp. 55–56. ISBN 978-0-387-97993-9.
- ↑ Graham, Knuth & Patashnik 1988, p. 156.
- ↑ Riordan, John (1958). An Introduction to Combinatorial Analysis. Wiley Publications in Mathematical Statistics. Chapman & Hall. p. 76. MR 0096594. Reprinted, Princeton Legacy Library, Princeton University Press, 2014, ISBN 9781400854332.
- ↑ 29.0 29.1 Graham, Knuth & Patashnik 1988, p. 195.
- ↑ Graham, Knuth & Patashnik 1988, p. 162.
- ↑ Randić, Milan (1987). "On the evaluation of the characteristic polynomial via symmetric function theory". Journal of Mathematical Chemistry. 1 (1): 145–152. doi:10.1007/BF01205340. MR 0895533. S2CID 121752631.
- ↑ Hill, Victor E. (2000). "8.1 Proposition: Symmetric group Sn". Groups and Characters. Chapman & Hall. p. 70. ISBN 978-1-351-44381-4. MR 1739394.
- ↑ Christensen, Kim; Moloney, Nicholas R. (2005). "Appendix A: Taylor expansion". Complexity and Criticality. Advanced physics texts. 1. Imperial College Press. p. 341. ISBN 978-1-86094-504-5.
- ↑ Wilf, Herbert S. (2006). generatingfunctionology (3rd ed.). Wellesley, Massachusetts: A K Peters. p. 22. ISBN 978-1-56881-279-3. MR 2172781.
- ↑ Ore, Øystein (1948). Number Theory and Its History. New York: McGraw-Hill. p. 66. MR 0026059. Reprinted, Courier Dover Publications, 1988, ISBN 9780486656205.
- ↑ 36.0 36.1 36.2 Caldwell, Chris K.; Gallot, Yves (2002). "On the primality of Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n!\pm1} and Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle 2\times3\times5\times\dots\times p\pm1} ". Mathematics of Computation. 71 (237): 441–448. doi:10.1090/S0025-5718-01-01315-1. MR 1863013.
- ↑ Guy, Richard K. (2004). "D25: Equations involving factorial Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} ". Unsolved Problems in Number Theory. Problem Books in Mathematics. 1 (3rd ed.). New York: Springer-Verlag. pp. 301–302. doi:10.1007/978-0-387-26677-0. ISBN 0-387-20860-7. MR 2076335.
- ↑ Neale, Vicky (2017). Closing the Gap: The Quest to Understand Prime Numbers. Oxford University Press. pp. 146–147. ISBN 978-0-19-878828-7.
- ↑ Erdős, Pál (1932). "Beweis eines Satzes von Tschebyschef" [Proof of a theorem of Chebyshev] (PDF). Acta Litt. Sci. Szeged (in German). 5: 194–198. Zbl 0004.10103.
- ↑ Chvátal, Vašek (2021). "1.5: Erdős's proof of Bertrand's postulate". The Discrete Mathematical Charms of Paul Erdős: A Simple Introduction. Cambridge, England: Cambridge University Press. pp. 7–10. doi:10.1017/9781108912181. ISBN 978-1-108-83183-3. MR 4282416. S2CID 242637862.
- ↑ Fraenkel, Aviezri S. (1985). "Systems of numeration". The American Mathematical Monthly. 92 (2): 105–114. doi:10.1080/00029890.1985.11971550. JSTOR 2322638. MR 0777556.
- ↑ Pitman, Jim (1993). "3.5: The Poisson distribution". Probability. New York: Springer. pp. 222–236. doi:10.1007/978-1-4612-4374-8. ISBN 978-0-387-94594-1.
- ↑ Pitman 1993, p. 153.
- ↑ Kleinberg, Jon; Tardos, Éva (2006). Algorithm Design. Addison-Wesley. p. 55.
- ↑ 45.0 45.1 Knuth, Donald E. (1998). The Art of Computer Programming, Volume 3: Sorting and Searching (2nd ed.). Addison-Wesley. p. 182. ISBN 978-0-321-63578-5.
- ↑ Sedgewick, Robert; Wayne, Kevin (2011). Algorithms (4th ed.). Addison-Wesley. p. 466. ISBN 978-0-13-276256-4.
- ↑ Kardar, Mehran (2007). Statistical Physics of Particles. Cambridge University Press. pp. 107–110, 181–184. ISBN 978-0-521-87342-0. OCLC 860391091.
- ↑ Cameron, Peter J. (1994). "2.4: Orders of magnitude". Combinatorics: Topics, Techniques, Algorithms. Cambridge University Press. pp. 12–14. ISBN 978-0-521-45133-8.
- ↑ Magnus, Robert (2020). "11.10: Stirling's approximation". Fundamental Mathematical Analysis. Springer Undergraduate Mathematics Series. Cham: Springer. p. 391. doi:10.1007/978-3-030-46321-2. ISBN 978-3-030-46321-2. MR 4178171. S2CID 226465639.
- ↑ Palmer, Edgar M. (1985). "Appendix II: Stirling's formula". Graphical Evolution: An introduction to the theory of random graphs. Wiley-Interscience Series in Discrete Mathematics. Chichester: John Wiley & Sons. pp. 127–128. ISBN 0-471-81577-2. MR 0795795.
- ↑ 51.0 51.1 51.2 Chen, Chao-Ping; Lin, Long (2012). "Remarks on asymptotic expansions for the gamma function". Applied Mathematics Letters. 25 (12): 2322–2326. doi:10.1016/j.aml.2012.06.025. MR 2967837.
- ↑ 52.0 52.1 Beiler, Albert H. (1966). Recreations in the Theory of Numbers: The Queen of Mathematics Entertains. Dover Recreational Math Series (2nd ed.). Courier Corporation. p. 49. ISBN 978-0-486-21096-4.
- ↑ Chvátal 2021. "1.4: Legendre's formula". pp. 6–7.
- ↑ 54.0 54.1 Robert, Alain M. (2000). "3.1: The Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle p} -adic valuation of a factorial". A Course in Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle p} -adic Analysis. Graduate Texts in Mathematics. 198. New York: Springer-Verlag. pp. 241–242. doi:10.1007/978-1-4757-3254-2. ISBN 0-387-98669-3. MR 1760253.
- ↑ Peitgen, Heinz-Otto; Jürgens, Hartmut; Saupe, Dietmar (2004). "Kummer's result and Legendre's identity". Chaos and Fractals: New Frontiers of Science. New York: Springer. pp. 399–400. doi:10.1007/b97624. ISBN 978-1-4684-9396-2.
- ↑ Alladi, Krishnaswami; Grinstead, Charles (1977). "On the decomposition of n! into prime powers". Journal of Number Theory. 9 (4): 452–458. doi:10.1016/0022-314x(77)90006-3.
- ↑ 57.0 57.1 Koshy, Thomas (2007). "Example 3.12". Elementary Number Theory with Applications (2nd ed.). Elsevier. p. 178. ISBN 978-0-08-054709-1.
- ↑ Template:Cite OEIS
- ↑ Diaconis, Persi (1977). "The distribution of leading digits and uniform distribution mod 1". Annals of Probability. 5 (1): 72–81. doi:10.1214/aop/1176995891. MR 0422186.
- ↑ Bird, R. S. (1972). "Integers with given initial digits". The American Mathematical Monthly. 79 (4): 367–370. doi:10.1080/00029890.1972.11993051. JSTOR 2978087. MR 0302553.
- ↑ Kempner, A. J. (1918). "Miscellanea". The American Mathematical Monthly. 25 (5): 201–210. doi:10.2307/2972639. JSTOR 2972639.
- ↑ Erdős, Paul; Kastanas, Ilias (1994). "The smallest factorial that is a multiple of n (solution to problem 6674)" (PDF). The American Mathematical Monthly. 101: 179. doi:10.2307/2324376. JSTOR 2324376..
- ↑ 63.0 63.1 63.2 Bhargava, Manjul (2000). "The factorial function and generalizations". The American Mathematical Monthly. 107 (9): 783–799. CiteSeerX 10.1.1.585.2265. doi:10.2307/2695734. JSTOR 2695734.
- ↑ Guy 2004. "B23: Equal products of factorials". p. 123.
- ↑ Luca, Florian (2007). "On factorials which are products of factorials". Mathematical Proceedings of the Cambridge Philosophical Society. 143 (3): 533–542. Bibcode:2007MPCPS.143..533L. doi:10.1017/S0305004107000308. MR 2373957. S2CID 120875316.
- ↑ 66.0 66.1 Davis, Philip J. (1959). "Leonhard Euler's integral: A historical profile of the gamma function". The American Mathematical Monthly. 66 (10): 849–869. doi:10.1080/00029890.1959.11989422. JSTOR 2309786. MR 0106810. Archived from the original on 2023-01-01. Retrieved 2021-12-20.
- ↑ 67.0 67.1 Borwein, Jonathan M.; Corless, Robert M. (2018). "Gamma and factorial in the Monthly". The American Mathematical Monthly. 125 (5): 400–424. arXiv:1703.05349. doi:10.1080/00029890.2018.1420983. MR 3785875. S2CID 119324101.
- ↑ Remmert, Reinhold (1996). "Wielandt's theorem about the Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \Gamma} -function". The American Mathematical Monthly. 103 (3): 214–220. doi:10.1080/00029890.1996.12004726. JSTOR 2975370. MR 1376175.
- ↑ Hadamard, J. (1968) [1894]. "Sur l'expression du produit 1·2·3· · · · ·(n−1) par une fonction entière" (PDF). Œuvres de Jacques Hadamard (in French). Paris: Centre National de la Recherche Scientifiques.
- ↑ Alzer, Horst (2009). "A superadditive property of Hadamard's gamma function". Abhandlungen aus dem Mathematischen Seminar der Universität Hamburg. 79 (1): 11–23. doi:10.1007/s12188-008-0009-5. MR 2541340. S2CID 123691692.
- ↑ Robert 2000. "7.1: The gamma function Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \Gamma_p} ". pp. 366–385.
- ↑ Ross, Bertram (1978). "The psi function". Mathematics Magazine. 51 (3): 176–179. doi:10.1080/0025570X.1978.11976704. JSTOR 2689999. MR 1572267.
- ↑ Brase, Charles Henry; Brase, Corrinne Pellillo (2014). Understandable Statistics: Concepts and Methods (11th ed.). Cengage Learning. p. 182. ISBN 978-1-305-14290-9.
- ↑ "math — Mathematical functions". Python 3 Documentation: The Python Standard Library. Retrieved 2021-12-21.
- ↑ "Factorial". Boost 1.78.0 Documentation: Math Special Functions. Retrieved 2021-12-21.
- ↑ Addis, Tom; Addis, Jan (2009). Drawing Programs: The Theory and Practice of Schematic Functional Programming. Springer. pp. 149–150. ISBN 978-1-84882-618-2.
- ↑ Chapman, Stephen J. (2019). "Example 5.2: The factorial function". MATLAB Programming for Engineers (6th ed.). Cengage Learning. p. 215. ISBN 978-0-357-03052-3.
- ↑ Hey, Tony; Pápay, Gyuri (2014). The Computing Universe: A Journey through a Revolution. Cambridge University Press. p. 64. ISBN 9781316123225.
- ↑ Bolboaca, Alexandru (2019). Hands-On Functional Programming with C++: An effective guide to writing accelerated functional code using C++17 and C++20. Packt Publishing. p. 188. ISBN 978-1-78980-921-3.
- ↑ Gray, John W. (2014). Mastering Mathematica: Programming Methods and Applications. Academic Press. pp. 233–234. ISBN 978-1-4832-1403-0.
- ↑ Torra, Vicenç (2016). Scala From a Functional Programming Perspective: An Introduction to the Programming Language. Lecture Notes in Computer Science. 9980. Springer. p. 96. ISBN 978-3-319-46481-7.
- ↑ Sussman, Gerald Jay (1982). "LISP, programming, and implementation". Functional Programming and Its Applications: An Advanced Course. CREST Advanced Courses. Cambridge University Press. pp. 29–72. ISBN 978-0-521-24503-6. See in particular p. 34.
- ↑ Chaudhuri, Ranjan (June 2003). "Do the arithmetic operations really execute in constant time?". ACM SIGCSE Bulletin. Association for Computing Machinery. 35 (2): 43–44. doi:10.1145/782941.782977. S2CID 13629142.
- ↑ 84.0 84.1 Fateman, Richard J. (April 11, 2006). "Comments on Factorial Programs" (PDF). University of California, Berkeley.
- ↑ 85.0 85.1 Winkler, Jürgen F. H.; Kauer, Stefan (March 1997). "Proving assertions is also useful". ACM SIGPLAN Notices. Association for Computing Machinery. 32 (3): 38–41. doi:10.1145/251634.251638. S2CID 17347501.
- ↑ 86.0 86.1 Borwein, Peter B. (1985). "On the complexity of calculating factorials". Journal of Algorithms. 6 (3): 376–380. doi:10.1016/0196-6774(85)90006-9. MR 0800727.
- ↑ Harvey, David; van der Hoeven, Joris (2021). "Integer multiplication in time Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle O(n \log n)} " (PDF). Annals of Mathematics. Second Series. 193 (2): 563–617. doi:10.4007/annals.2021.193.2.4. MR 4224716. S2CID 109934776.
- ↑ Arndt, Jörg (2011). "34.1.1.1: Computation of the factorial". Matters Computational: Ideas, Algorithms, Source Code (PDF). Springer. pp. 651–652. See also "34.1.5: Performance", pp. 655–656.
- ↑ 89.0 89.1 Schönhage, Arnold (1994). Fast algorithms: a multitape Turing machine implementation. B.I. Wissenschaftsverlag. p. 226.
- ↑ Guy 2004. "B43: Alternating sums of factorials". pp. 152–153.
- ↑ 91.0 91.1 Callan, David (2009). "A combinatorial survey of identities for the double factorial". arXiv:0906.1317 [math.CO].
- ↑ Meserve, B. E. (1948). "Classroom Notes: Double Factorials". The American Mathematical Monthly. 55 (7): 425–426. doi:10.2307/2306136. JSTOR 2306136. MR 1527019.
- ↑ Mezey, Paul G. (2009). "Some dimension problems in molecular databases". Journal of Mathematical Chemistry. 45 (1): 1–6. doi:10.1007/s10910-008-9365-8. S2CID 120103389..
- ↑ Dale, M. R. T.; Moon, J. W. (1993). "The permuted analogues of three Catalan sets". Journal of Statistical Planning and Inference. 34 (1): 75–87. doi:10.1016/0378-3758(93)90035-5. MR 1209991..
- ↑ Luca, Florian; Marques, Diego (2010). "Perfect powers in the summatory function of the power tower". Journal de Théorie des Nombres de Bordeaux. 22 (3): 703–718. doi:10.5802/jtnb.740. MR 2769339.
- ↑ Graham, Knuth & Patashnik 1988, pp. x, 47–48.
- ↑ Sagan, Bruce E. (2020). "Theorem 1.2.1". Combinatorics: the Art of Counting. Graduate Studies in Mathematics. 210. Providence, Rhode Island: American Mathematical Society. p. 5. ISBN 978-1-4704-6032-7. MR 4249619.
- ↑ Hardy, G. H. (1921). "Examples XLV". A Course of Pure Mathematics (3rd ed.). Cambridge University Press. p. 215.
- ↑ Daley, D. J.; Vere-Jones, D. (1988). "5.2: Factorial moments, cumulants, and generating function relations for discrete distributions". An Introduction to the Theory of Point Processes. Springer Series in Statistics. New York: Springer-Verlag. p. 112. ISBN 0-387-96666-8. MR 0950166.
- ↑ Template:Cite OEIS
- ↑ Kinkelin, H. (1860). "Ueber eine mit der Gammafunction verwandte Transcendente und deren Anwendung auf die Integralrechung" [On a transcendental variation of the gamma function and its application to the integral calculus]. Journal für die reine und angewandte Mathematik (in German). 1860 (57): 122–138. doi:10.1515/crll.1860.57.122. S2CID 120627417.
- ↑ Glaisher, J. W. L. (1877). "On the product 11.22.33...nn". Messenger of Mathematics. 7: 43–47.
- ↑ Aebi, Christian; Cairns, Grant (2015). "Generalizations of Wilson's theorem for double-, hyper-, sub- and superfactorials". The American Mathematical Monthly. 122 (5): 433–443. doi:10.4169/amer.math.monthly.122.5.433. JSTOR 10.4169/amer.math.monthly.122.5.433. MR 3352802. S2CID 207521192.
- ↑ Template:Cite OEIS
- ↑ Nelson, Randolph (2020). A Brief Journey in Discrete Mathematics. Cham: Springer. p. 127. doi:10.1007/978-3-030-37861-5. ISBN 978-3-030-37861-5. MR 4297795. S2CID 213895324.
- ↑ Barnes, E. W. (1900). "The theory of the G-function". The Quarterly Journal of Pure and Applied Mathematics. 31: 264–314. JFM 30.0389.02.
- ↑ Template:TAOCP
External links
| File:Commons-logo.svg | Wikimedia Commons has media related to Factorial (function). |