Pengguna:Dedhert.Jr/Uji halaman 01/13: Perbedaan antara revisi
Konten dihapus Konten ditambahkan
Dedhert.Jr (bicara | kontrib) |
Dedhert.Jr (bicara | kontrib) Tidak ada ringkasan suntingan |
||
(1 revisi perantara oleh pengguna yang sama tidak ditampilkan) | |||
Baris 6:
{| class="wikitable" style="margin:0 0 0 1em; text-align:right; float:right;"
|+
!<math>n</math>
!<math>n!</math>
Baris 125:
== Sejarah ==
Konsep faktorial muncul secara terpisah dalam banyak budaya.
* Dalam [[matematika India]], salah satu penjelasan tentang faktorial yang paling awal diketahui berasal dari Anuyogadvāra-sūtra,<ref name="datta-singh">{{cite book|last1=Datta|first1=Bibhutibhusan|last2=Singh|first2=Awadhesh Narayan|year=2019|title=Studies in Indian Mathematics and Astronomy: Selected Articles of Kripa Shankar Shukla|publisher=Springer Singapore|editor1-last=Kolachana|editor1-first=Aditya|series=Sources and Studies in the History of Mathematics and Physical Sciences|pages=356–376|contribution=Use of permutations and combinations in India|doi=10.1007/978-981-13-7326-8_18|author1-link=Bibhutibhushan Datta|editor2-last=Mahesh|editor2-first=K.|editor3-last=Ramasubramanian|editor3-first=K.|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> salah satu tulisan karya [[kesusasteraan Jain]], <u>which has been assigned dates varying from 300 BCE to 400 CE</u>.<ref>{{cite journal|last=Jadhav|first=Dipak|date=August 2021|title=Jaina Thoughts on Unity Not Being a Number|journal=History of Science in South Asia|publisher=University of Alberta Libraries|volume=9|pages=209–231|doi=10.18732/hssa67|s2cid=238656716}}. 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" /> 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|mr=0530622|doi-access=free}}</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|title=Ethnomathematics in the classroom|journal=[[For the Learning of Mathematics]]|volume=14|issue=2|pages=26–30|jstor=40248112}}</ref><ref>[[wikisource: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|prime numbers]].<ref>{{cite journal|last=Rashed|first=Roshdi|author-link=Roshdi Rashed|year=1980|title=Ibn al-Haytham et le théorème de Wilson|journal=[[Archive for History of Exact Sciences]]|language=fr|volume=22|issue=4|pages=305–321|doi=10.1007/BF00717654|mr=595903|s2cid=120885025}}</ref>
* In Europe, although [[Greek mathematics]] included some combinatorics, and [[Plato]] famously used 5040 (a factorial) as the population of an ideal community, in part because of its divisibility properties,<ref>{{cite journal|last=Acerbi|first=F.|year=2003|title=On the shoulders of Hipparchus: a reappraisal of ancient Greek combinatorics|journal=[[Archive for History of Exact Sciences]]|volume=57|issue=6|pages=465–502|doi=10.1007/s00407-003-0067-0|jstor=41134173|mr=2004966|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|last=Katz|first=Victor J.|date=2013|title=Combinatorics: Ancient & Modern|publisher=[[Oxford University Press]]|isbn=978-0-19-965659-2|editor1-last=Wilson|editor1-first=Robin|pages=109–121|contribution=Chapter 4: Jewish combinatorics|author-link=Victor J. Katz|editor2-last=Watkins|editor2-first=John J.}} 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|title=The Art of Changes: Bell-Ringing, Anagrams, and the Culture of Combination in Seventeenth-Century England|journal=Journal of Medieval and Early Modern Studies|volume=48|issue=2|pages=387–412|doi=10.1215/10829636-4403136}}</ref><ref>{{cite book|last=Stedman|first=Fabian|year=1677|title=Campanalogia|place=London|pages=6–9|author-link=Fabian Stedman}} 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|last=Knobloch|first=Eberhard|date=2013|title=Combinatorics: Ancient & Modern|publisher=[[Oxford University Press]]|isbn=978-0-19-965659-2|editor1-last=Wilson|editor1-first=Robin|pages=123–145|contribution=Chapter 5: Renaissance combinatorics|author-link=Eberhard Knobloch|editor2-last=Watkins|editor2-first=John J.}} 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.|last2=Hermes|first2=H.|last3=Hirzebruch|first3=F.|last4=Koecher|first4=M.|last5=Mainzer|first5=K.|last6=Neukirch|first6=J.|last7=Prestel|first7=A.|last8=Remmert|first8=R.|year=1990|url=https://books.google.com/books?id=Z53SBwAAQBAJ&pg=PA131|title=Numbers|location=New York|publisher=Springer-Verlag|isbn=0-387-97202-1|series=Graduate Texts in Mathematics|volume=123|page=131|doi=10.1007/978-1-4612-1005-4|mr=1066206|author1-link=Heinz-Dieter Ebbinghaus|author2-link=Hans Hermes|author3-link=Friedrich Hirzebruch|author4-link=Max Koecher|author5-link=Klaus Mainzer|author6-link=Jürgen Neukirch|author8-link=Reinhold Remmert}}</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|year=1991|title=The early history of the factorial function|journal=[[Archive for History of Exact Sciences]]|volume=43|issue=3|pages=225–249|doi=10.1007/BF00389433|jstor=41133918|mr=1171521|s2cid=122237769}}</ref> [[Adrien-Marie Legendre]] included [[Legendre's formula]], describing the exponents in the [[Integer factorization|factorization]] of factorials into [[Prime power|prime powers]], in an 1808 text on [[number theory]].<ref>{{cite book|last=Dickson|first=Leonard E.|year=1919|title=History of the Theory of Numbers|title-link=History of the Theory of Numbers|publisher=Carnegie Institution of Washington|volume=1|pages=263–278|contribution=Chapter IX: Divisibility of factorials and multinomial coefficients|author-link=Leonard Eugene Dickson|contribution-url=https://archive.org/details/historyoftheoryo01dick/page/262}} See in particular p. 263.</ref>
== Definisi ==
Fungsi faktorial suatu bilangan bulat positif <math>n</math> didefinisikan melalui hasil kali<ref name="gkp2" /><math display="block">n! = 1 \cdot 2 \cdot 3 \cdots (n-2) \cdot (n-1) \cdot n.</math>Rumus di atas dapat ditulis lebih singkat melalui [[notasi kapital Pi]]<ref name="gkp2" /><math display="block">n! = \prod_{i = 1}^n i.</math>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 {{nowrap|by <math>n</math>:<ref name=hamkins/>}}<math display="block"> n! = n\cdot (n-1)!.</math>Sebagai contoh, {{nowrap|<math>5! = 5\cdot 4!=5\cdot 24=120</math>.}}
=== Faktorial dari 0 ===
Faktorial {{nowrap|dari <math>0</math>}} {{nowrap|adalah <math>1</math>,}} atau dapat dituliskan dalam bentuk simbol, {{nowrap|<math>0!=1</math>.}} Ada beberapa alasan mengenai definisi ini:
* Untuk {{nowrap|<math>n=0</math>,}} definisi <math>n!</math> sebagai hasil kali melibatkan hasil kali tanpa adanya bilangan sama sekali, dan demikian definisi tersebut merupakan sebuah contoh konvensi yang luas bahwa [[darab kosong]], darab tanpa adanya faktor, sama dengan identitas perkaliannya.<ref>{{cite book|last=Dorf|first=Richard C.|year=2003|title=CRC Handbook of Engineering Tables|publisher=CRC Press|isbn=978-0-203-00922-2|page=5-5|contribution=Factorials|contribution-url=https://books.google.com/books?id=TCLOBgAAQBAJ&pg=SA5-PA5}}</ref>
* Ada setidaknya satu permutasi dari nol benda, yang berarti tidak ada benda yang diurutkan dan tidak ada benda yang disusun kembali.<ref name="hamkins">{{cite book|last=Hamkins|first=Joel David|year=2020|url=https://books.google.com/books?id=Ns_tDwAAQBAJ&pg=PA50|title=Proof and the Art of Mathematics|location=Cambridge, Massachusetts|publisher=MIT Press|isbn=978-0-262-53979-1|page=50|mr=4205951|author-link=Joel David Hamkins}}</ref>
* Konvensi ini membuat banyak identitas dalam [[kombinatorik]], yang valid untuk semua pilihan valid mengenai parameternya. Sebagai contoh, banyaknya cara untuk memilih semua <math>n</math> anggota dari sebuah himpunan dari <math>n</math> adalah <math display="inline">\tbinom{n}{n} = \tfrac{n!}{n!0!} = 1,</math> identitas [[koefisien binomial]] yang akan valid {{nowrap|karena <math>0!=1</math>.<ref>{{cite journal | last1 = Goldenberg | first1 = E. Paul | last2 = Carter | first2 = Cynthia J. | date = October 2017 | doi = 10.5951/mathteacher.111.2.0104 | issue = 2 | journal = [[The Mathematics Teacher]] | jstor = 10.5951/mathteacher.111.2.0104 | pages = 104–110 | title = A student asks about (−5)! | volume = 111}}</ref>}}
* Karena {{nowrap|<math>0!=1</math>,}} relasi rekurensi mengenai faktorial tetap valid {{nowrap|di <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|editor4-last=Utting|title=Proceedings of the 7th Annual SIGCSE Conference on Innovation and Technology in Computer Science Education, ITiCSE 2002, Aarhus, Denmark, June 24-28, 2002|publisher=Association for Computing Machinery|pages=84–88|doi=10.1145/544414.544441|contribution=The case of base cases: Why are they so difficult to recognize? Student difficulties with recursion|editor4-first=Ian|editor3-first=Don|first1=Bruria|editor3-last=Goelman|editor2-first=Daniel T.|editor2-last=Joyce|editor1-first=Michael E.|editor1-last=Caspersen|first2=Haim|last2=Averbuch|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/>}}
* This choice matches the [[gamma function]] {{nowrap|<math>0! = \Gamma(0+1) = 1</math>,}} and the gamma function must have this value to be a [[continuous function]].<ref>{{cite book|last1=Farrell|first1=Orin J.|last2=Ross|first2=Bertram|year=1971|url=https://books.google.com/books?id=fXPDAgAAQBAJ&pg=PA10|title=Solved Problems in Analysis: As Applied to Gamma, Beta, Legendre and Bessel Functions|publisher=Courier Corporation|isbn=978-0-486-78308-6|series=Dover Books on Mathematics|page=10}}</ref>
== Penerapan ==
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|last1=Conway|first1=John H.|last2=Guy|first2=Richard|year=1998|title=The Book of Numbers|publisher=Springer Science & Business Media|isbn=978-0-387-97993-9|pages=55–56|language=en|contribution=Factorial numbers|author-link=John Horton Conway|author-link2=Richard K. Guy}}</ref> Factorials appear more broadly in many formulas in [[combinatorics]], to account for different orderings of objects. For instance the [[Binomial coefficient|binomial coefficients]] <math>\tbinom{n}{k}</math> count the {{nowrap|<math>k</math>-element}} [[Combination|combinations]] (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|year=1958|url=https://books.google.com/books?id=Sbb_AwAAQBAJ&pg=PA76|title=An Introduction to Combinatorial Analysis|publisher=Chapman & Hall|isbn=9781400854332|series=Wiley Publications in Mathematical Statistics|page=76|mr=0096594|author-link=John Riordan (mathematician)}}</ref> Another combinatorial application is in counting [[Derangement|derangements]], 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|symmetric polynomials]].<ref>{{cite journal|last=Randić|first=Milan|year=1987|title=On the evaluation of the characteristic polynomial via symmetric function theory|journal=Journal of Mathematical Chemistry|volume=1|issue=1|pages=145–152|doi=10.1007/BF01205340|mr=895533|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|symmetric groups]].<ref>{{cite book|last=Hill|first=Victor E.|year=2000|title=Groups and Characters|publisher=Chapman & Hall|isbn=978-1-351-44381-4|page=70|contribution=8.1 Proposition: Symmetric group {{math|''S''<sub>''n''</sub>}}|mr=1739394|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="craik2" /> In [[mathematical analysis]], factorials frequently appear in the denominators of [[power series]], most notably in the series for the [[exponential function]],<ref name="exponential-series2" /><math display="block">e^x=1+\frac{x}{1}+\frac{x^2}{2}+\frac{x^3}{6}+\cdots=\sum_{i=0}^{\infty}\frac{x^i}{i!},</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.|year=2006|url=https://books.google.com/books?id=XOPMBQAAQBAJ&pg=PA22|title=generatingfunctionology|location=Wellesley, Massachusetts|publisher=A K Peters|isbn=978-1-56881-279-3|edition=3rd|page=22|mr=2172781|author-link=Herbert Wilf}}</ref><math display="block">\sum_{i=0}^{\infty} \frac{x^i n_i}{i!}.</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|prime numbers]] can be found as the prime factors of the numbers <math>n!\pm 1</math>, leading to a proof of [[Euclid's theorem]] that the number of primes is infinite.<ref>{{cite book|last=Ore|first=Øystein|year=1948|url=https://books.google.com/books?id=Sl_6BPp7S0AC&pg=PA66|title=Number Theory and Its History|location=New York|publisher=McGraw-Hill|isbn=9780486656205|page=66|mr=0026059|author-link=Øystein Ore}}</ref> When <math>n!\pm 1</math> is itself prime it is called a [[factorial prime]];<ref name="caldwell-gallot">{{cite journal|last1=Caldwell|first1=Chris K.|last2=Gallot|first2=Yves|year=2002|title=On the primality of <math>n!\pm1</math> and <math>2\times3\times5\times\dots\times p\pm1</math>|journal=[[Mathematics of Computation]]|volume=71|issue=237|pages=441–448|doi=10.1090/S0025-5718-01-01315-1|mr=1863013}}</ref> relatedly, [[Brocard's problem]], also posed by [[Srinivasa Ramanujan]], concerns the existence of [[Square number|square numbers]] of the form {{nowrap|<math>n!+1</math>.<ref>{{cite book | last = Guy | first = Richard K. | author-link = Richard K. Guy | contribution = D25: Equations involving factorial <math>n</math> | doi = 10.1007/978-0-387-26677-0 | edition = 3rd | isbn = 0-387-20860-7 | mr = 2076335 | pages = 301–302 | publisher = Springer-Verlag | location = New York | series = Problem Books in Mathematics | title = Unsolved Problems in Number Theory | year = 2004| volume = 1 }}</ref>}} In contrast, the numbers <math>n!+2,n!+3,\dots n!+n</math> must all be composite, proving the existence of arbitrarily large [[Prime gap|prime gaps]].<ref>{{cite book|last=Neale|first=Vicky|year=2017|url=https://books.google.com/books?id=T7Q1DwAAQBAJ&pg=PA146|title=Closing the Gap: The Quest to Understand Prime Numbers|publisher=Oxford University Press|isbn=978-0-19-878828-7|pages=146–147|author-link=Vicky Neale}}</ref> An elementary [[proof of Bertrand's postulate]] on the existence of a prime in any interval of the {{nowrap|form <math>[n,2n]</math>,}} one of the first results of [[Paul Erdős]], was based on the divisibility properties of factorials.<ref>{{cite journal|last=Erdős|first=Pál|author-link=Paul Erdős|year=1932|title=Beweis eines Satzes von Tschebyschef|trans-title=Proof of a theorem of Chebyshev|url=https://users.renyi.hu/~p_erdos/1932-01.pdf|journal=Acta Litt. Sci. Szeged|language=de|volume=5|pages=194–198|zbl=0004.10103}}</ref><ref>{{cite book|last=Chvátal|first=Vašek|year=2021|title=The Discrete Mathematical Charms of Paul Erdős: A Simple Introduction|location=Cambridge, England|publisher=Cambridge University Press|isbn=978-1-108-83183-3|pages=7–10|contribution=1.5: Erdős's proof of Bertrand's postulate|doi=10.1017/9781108912181|mr=4282416|author-link=Václav Chvátal|contribution-url=https://books.google.com/books?id=_gVDEAAAQBAJ&pg=PA7|s2cid=242637862}}</ref> The [[factorial number system]] is a [[mixed radix]] notation for numbers in which the place values of each digit are factorials.<ref>{{cite journal|last=Fraenkel|first=Aviezri S.|author-link=Aviezri Fraenkel|year=1985|title=Systems of numeration|journal=[[The American Mathematical Monthly]]|volume=92|issue=2|pages=105–114|doi=10.1080/00029890.1985.11971550|jstor=2322638|mr=777556}}</ref>
Factorials are used extensively in [[probability theory]], for instance in the [[Poisson distribution]]<ref>{{cite book|last=Pitman|first=Jim|year=1993|title=Probability|location=New York|publisher=Springer|isbn=978-0-387-94594-1|pages=222–236|contribution=3.5: The Poisson distribution|doi=10.1007/978-1-4612-4374-8}}</ref> and in the probabilities of [[Random permutation|random permutations]].{{sfn|Pitman|1993|p=153}} In [[computer science]], beyond appearing in the analysis of [[Brute-force search|brute-force searches]] over permutations,<ref>{{cite book|last1=Kleinberg|first1=Jon|last2=Tardos|first2=Éva|year=2006|title=Algorithm Design|publisher=Addison-Wesley|page=55|author1-link=Jon Kleinberg|author2-link=Éva Tardos}}</ref> factorials arise in the [[lower bound]] of <math>\log_2 n!=n\log_2n-O(n)</math> on the number of comparisons needed to [[comparison sort]] a set of <math>n</math> items,<ref name="knuth-sorting" /> and in the analysis of chained [[Hash table|hash tables]], where the distribution of keys per cell can be accurately approximated by a Poisson distribution.<ref>{{cite book|last1=Sedgewick|first1=Robert|last2=Wayne|first2=Kevin|year=2011|url=https://books.google.com/books?id=idUdqdDXqnAC&pg=PA466|title=Algorithms|publisher=Addison-Wesley|isbn=978-0-13-276256-4|edition=4th|page=466|author1-link=Robert Sedgewick (computer scientist)}}</ref> Moreover, factorials naturally appear in formulae from [[Quantum mechanics|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 [[Microstate (statistical mechanics)|microstates]] by dividing by the factorials of the numbers of each type of [[Identical particles|indistinguishable particle]] to avoid the [[Gibbs paradox]]. Quantum physics provides the underlying reason for why these corrections are necessary.<ref>{{cite book|last=Kardar|first=Mehran|year=2007|title=Statistical Physics of Particles|title-link=Statistical Physics of Particles|publisher=[[Cambridge University Press]]|isbn=978-0-521-87342-0|pages=107–110, 181–184|oclc=860391091|author-link=Mehran Kardar}}</ref>
== Sifat-sifat ==
=== Pertumbuhan dan aproksimasi ===
[[Berkas:Mplwp_factorial_stirling_loglog2.svg|jmpl|Comparison of the factorial, Stirling's approximation, and the simpler approximation {{nowrap|<math>(n/e)^n</math>,}} on a doubly logarithmic scale]]
[[Berkas:Stirling_series_relative_error.svg|jmpl|[[Relative error]] in a truncated Stirling series vs. number of terms]]
{{main|Aproksimasi Stirling}}
As a function {{nowrap|of <math>n</math>,}} the factorial has faster than [[exponential growth]], but grows more slowly than a [[double exponential function]].<ref>{{cite book|last=Cameron|first=Peter J.|year=1994|title=Combinatorics: Topics, Techniques, Algorithms|publisher=Cambridge University Press|isbn=978-0-521-45133-8|pages=12–14|contribution=2.4: Orders of magnitude|author-link=Peter Cameron (mathematician)}}</ref> Its growth rate is similar {{nowrap|to <math>n^n</math>,}} 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:<math display="block">\ln n! = \sum_{x=1}^n \ln x \approx \int_1^n\ln x\, dx=n\ln n-n+1.</math>Exponentiating the result (and ignoring the negligible <math>+1</math> term) approximates <math>n!</math> as {{nowrap|<math>(n/e)^n</math>.<ref>{{cite book | last = Magnus | first = Robert | contribution = 11.10: Stirling's approximation | contribution-url = https://books.google.com/books?id=5hvxDwAAQBAJ&pg=PA391 | doi = 10.1007/978-3-030-46321-2 | isbn = 978-3-030-46321-2 | location = Cham | mr = 4178171 | page = 391 | publisher = Springer | series = Springer Undergraduate Mathematics Series | title = Fundamental Mathematical Analysis | year = 2020| s2cid = 226465639 }}</ref>}} More carefully bounding the sum both above and below by an integral, using the [[trapezoid rule]], shows that this estimate needs a correction term 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.|year=1985|title=Graphical Evolution: An introduction to the theory of random graphs|location=Chichester|publisher=John Wiley & Sons|isbn=0-471-81577-2|series=Wiley-Interscience Series in Discrete Mathematics|pages=127–128|contribution=Appendix II: Stirling's formula|mr=795795}}</ref><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 one 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|year=2012|title=Remarks on asymptotic expansions for the gamma function|journal=Applied Mathematics Letters|volume=25|issue=12|pages=2322–2326|doi=10.1016/j.aml.2012.06.025|mr=2967837}}</ref><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>An alternative version uses only odd exponents in the correction terms:<ref name="asymptotic" /><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>Many other variations of these formulas have also been developed, by [[Srinivasa Ramanujan]], [[Bill Gosper]], and others.<ref name="asymptotic" />
The [[binary logarithm]] of the factorial, used to analyze [[Comparison sort|comparison sorting]], 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-sorting2">{{cite book|last=Knuth|first=Donald E.|year=1998|url=https://books.google.com/books?id=cYULBAAAQBAJ&pg=PA182|title=The Art of Computer Programming, Volume 3: Sorting and Searching|publisher=Addison-Wesley|isbn=978-0-321-63578-5|edition=2nd|page=182|author-link=Donald Knuth}}</ref><math display="block">\log_2 n! = n\log_2 n-(\log_2 e)n + \frac12\log_2 n + O(1).</math>
=== Keterbagian dan digit ===
{{main|Rumus Legendre}}
The product formula for the factorial implies that <math>n!</math> is [[divisible]] by all [[Prime number|prime numbers]] that are at {{nowrap|most <math>n</math>,}} and by no larger prime numbers.<ref name="beiler">{{cite book|last=Beiler|first=Albert H.|year=1966|url=https://books.google.com/books?id=NbbbL9gMJ88C&pg=PA49|title=Recreations in the Theory of Numbers: The Queen of Mathematics Entertains|publisher=Courier Corporation|isbn=978-0-486-21096-4|edition=2nd|series=Dover Recreational Math Series|page=49}}</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.|year=2000|title=A Course in {{nowrap|<math>p</math>-adic}} Analysis|location=New York|publisher=Springer-Verlag|isbn=0-387-98669-3|series=[[Graduate Texts in Mathematics]]|volume=198|pages=241–242|contribution=3.1: The {{nowrap|<math>p</math>-adic}} valuation of a factorial|doi=10.1007/978-1-4757-3254-2|mr=1760253|author-link=Alain M. Robert}}</ref><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>,}} and the exponent given by this formula can also be interpreted in advanced mathematics as the [[P-adic order|{{mvar|p}}-adic valuation]] of the factorial.<ref name="padic" /> Applying Legendre's formula to the product formula for [[Binomial coefficient|binomial coefficients]] 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|first1=Heinz-Otto|last2=Jürgens|first2=Hartmut|last3=Saupe|first3=Dietmar|year=2004|title=Chaos and Fractals: New Frontiers of Science|location=New York|publisher=Springer|isbn=978-1-4684-9396-2|pages=399–400|contribution=Kummer's result and Legendre's identity|doi=10.1007/b97624|author1-link=Heinz-Otto Peitgen|author2-link=Hartmut Jürgens|author3-link=Dietmar Saupe}}</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">{{cite book|last=Koshy|first=Thomas|year=2007|title=Elementary Number Theory with Applications|publisher=Elsevier|isbn=978-0-08-054709-1|edition=2nd|page=178|contribution=Example 3.12|contribution-url=https://books.google.com/books?id=d5Z5I3gnFh0C&pg=PA178}}</ref> 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" /> The leading digits of the factorials are distributed according to [[Benford's law]].<ref>{{cite journal|last=Diaconis|first=Persi|author-link=Persi Diaconis|year=1977|title=The distribution of leading digits and uniform distribution mod 1|journal=[[Annals of Probability]]|volume=5|issue=1|pages=72–81|doi=10.1214/aop/1176995891|mr=422186}}</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)|year=1972|title=Integers with given initial digits|journal=[[The American Mathematical Monthly]]|volume=79|issue=4|pages=367–370|doi=10.1080/00029890.1972.11993051|jstor=2978087|mr=302553}}</ref>
Another result on divisibility of factorials, [[Wilson's theorem]], states that <math>(n-1)!+1</math> is divisible by <math>n</math> if and only if <math>n</math> is a [[prime number]].<ref name="beiler" /> For any given {{nowrap|integer <math>x</math>,}} the [[Kempner function]] of <math>x</math> is given by the smallest <math>n</math> for which <math>x</math> divides {{nowrap|<math>n!</math>.<ref>{{cite journal | jstor = 2972639 | first = A. J. | last = Kempner | title = Miscellanea | journal = [[The American Mathematical Monthly]] | volume = 25 | pages = 201–210 | year = 1918 | doi = 10.2307/2972639 | issue = 5}}</ref>}} For almost all numbers (all but a subset of exceptions with [[asymptotic density]] zero), it coincides with the largest prime factor {{nowrap|of <math>x</math>.<ref>{{cite journal|title=The smallest factorial that is a multiple of {{mvar|n}} (solution to problem 6674)|journal=[[The American Mathematical Monthly]]|volume=101|year=1994|page=179|url=http://www-fourier.ujf-grenoble.fr/~marin/une_autre_crypto/articles_et_extraits_livres/irationalite/Erdos_P._Kastanas_I.The_smallest_factorial...-.pdf|first1=Paul|last1=Erdős|author1-link=Paul Erdős|first2=Ilias|last2=Kastanas|doi=10.2307/2324376|jstor=2324376}}.</ref>}}
The product of two factorials, {{nowrap|<math>m!\cdot n!</math>,}} always evenly divides {{nowrap|<math>(m+n)!</math>.<ref name=bhargava/>}} There are infinitely many factorials that equal the product of other factorials: if <math>n</math> is itself any product of factorials, then <math>n!</math> equals that same product multiplied by one more factorial, {{nowrap|<math>(n-1)!</math>.}} The only known examples of factorials that are products of other factorials but are not of this "trivial" form are {{nowrap|<math>9!=7!\cdot 3!\cdot 3!\cdot 2!</math>,}} {{nowrap|<math>10!=7!\cdot 6!=7!\cdot 5!\cdot 3!</math>,}} and {{nowrap|<math>16!=14!\cdot 5!\cdot 2!</math>.<ref>{{harvnb|Guy|2004}}. "B23: Equal products of factorials". p. 123.</ref>}} It would follow from the [[Abc conjecture|{{mvar|abc}} conjecture]] that there are only finitely many nontrivial examples.<ref>{{cite journal|last=Luca|first=Florian|author-link=Florian Luca|year=2007|title=On factorials which are products of factorials|journal=[[Mathematical Proceedings of the Cambridge Philosophical Society]]|volume=143|issue=3|pages=533–542|bibcode=2007MPCPS.143..533L|doi=10.1017/S0305004107000308|mr=2373957|s2cid=120875316}}</ref>
The [[greatest common divisor]] of the values of a [[Primitive part and content|primitive polynomial]] of degree <math>d</math> over the integers evenly divides {{nowrap|<math>d!</math>.<ref name=bhargava>{{cite journal | last = Bhargava | first = Manjul | author-link = Manjul Bhargava | url = https://www.maa.org/programs/maa-awards/writing-awards/the-factorial-function-and-generalizations | title = The factorial function and generalizations | journal = [[The American Mathematical Monthly]] | volume = 107 | year = 2000 | pages = 783–799 | doi = 10.2307/2695734 | issue = 9 | jstor = 2695734 | citeseerx = 10.1.1.585.2265
}}</ref>}}
=== Interpolasi kontinu dan perumuman bukan bilangan bulat ===
[[Berkas:Generalized_factorial_function_more_infos.svg|jmpl|The gamma function (shifted one unit left to match the factorials) continuously interpolates the factorial to non-integer values]]
[[Berkas:Gamma_abs_3D.png|jmpl|Absolute values of the complex gamma function, showing poles at non-positive integers]]
{{Main|Fungsi gamma}}
There are infinitely many ways to extend the factorials to a [[continuous function]].<ref name="davis">{{cite journal|last=Davis|first=Philip J.|author-link=Philip J. Davis|year=1959|title=Leonhard Euler's integral: A historical profile of the gamma function|url=https://www.maa.org/programs/maa-awards/writing-awards/leonhard-eulers-integral-an-historical-profile-of-the-gamma-function|journal=[[The American Mathematical Monthly]]|volume=66|issue=10|pages=849–869|doi=10.1080/00029890.1959.11989422|jstor=2309786|mr=106810}}</ref> The most widely used of these<ref name="borwein-corless">{{cite journal|last1=Borwein|first1=Jonathan M.|last2=Corless|first2=Robert M.|year=2018|title=Gamma and factorial in the ''Monthly''|journal=[[The American Mathematical Monthly]]|volume=125|issue=5|pages=400–424|arxiv=1703.05349|doi=10.1080/00029890.2018.1420983|mr=3785875|author1-link=Jonathan Borwein|s2cid=119324101}}</ref> uses the [[gamma function]], which can be defined for positive real numbers as the [[integral]]<math display="block"> \Gamma(z) = \int_0^\infty x^{z-1} e^{-x}\,dx.</math>The resulting function is related to the factorial of a non-negative integer <math>n</math> by the equation<math display="block"> n!=\Gamma(n+1),</math>which can be used as a definition of the factorial for non-integer arguments. At all values <math>x</math> for which both <math>\Gamma(x)</math> and <math>\Gamma(x-1)</math> are defined, the gamma function obeys the [[functional equation]]<math display="block"> \Gamma(n)=(n-1)\Gamma(n-1),</math>generalizing the [[recurrence relation]] for the factorials.<ref name="davis" />
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>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" /> 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|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.<ref>{{cite journal|last=Remmert|first=Reinhold|author-link=Reinhold Remmert|year=1996|title=Wielandt's theorem about the {{nowrap|<math>\Gamma</math>-function}}|journal=[[The American Mathematical Monthly]]|volume=103|issue=3|pages=214–220|doi=10.1080/00029890.1996.12004726|jstor=2975370|mr=1376175}}</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|last=Hadamard|first=J.|date=1968|title=Œuvres de Jacques Hadamard|location=Paris|publisher=Centre National de la Recherche Scientifiques|language=fr|chapter=Sur l'expression du produit {{math|1·2·3· · · · ·(''n''−1)}} par une fonction entière|author-link=Jacques Hadamard|chapter-url=http://www.luschny.de/math/factorial/hadamard/HadamardFactorial.pdf|orig-date=1894}}</ref><ref>{{cite journal|last=Alzer|first=Horst|year=2009|title=A superadditive property of Hadamard's gamma function|journal=Abhandlungen aus dem Mathematischen Seminar der Universität Hamburg|volume=79|issue=1|pages=11–23|doi=10.1007/s12188-008-0009-5|mr=2541340|s2cid=123691692}}</ref> In the [[P-adic number|{{mvar|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 {{mvar|p}}-adics) 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|harmonic numbers]], offset by the [[Euler–Mascheroni constant]].<ref>{{cite journal|last=Ross|first=Bertram|year=1978|title=The psi function|journal=[[Mathematics Magazine]]|volume=51|issue=3|pages=176–179|doi=10.1080/0025570X.1978.11976704|jstor=2689999|mr=1572267}}</ref>
=== Perhitungan ===
[[Berkas:Vintage_Texas_Instruments_Model_SR-50A_Handheld_LED_Electronic_Calculator,_Made_in_the_USA,_Price_Was_$109.50_in_1975_(8715012843).jpg|jmpl|[[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|scientific calculators]].<ref>{{cite book|last1=Brase|first1=Charles Henry|last2=Brase|first2=Corrinne Pellillo|year=2014|url=https://books.google.com/books?id=a8OiAgAAQBAJ&pg=PA182|title=Understandable Statistics: Concepts and Methods|publisher=Cengage Learning|isbn=978-1-305-14290-9|edition=11th|page=182}}</ref> It is also included in scientific programming libraries such as the [[Python (programming language)|Python]] mathematical functions module<ref>{{cite web|title=math — Mathematical functions|url=https://docs.python.org/3/library/math.html|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|title=Factorial|url=https://www.boost.org/doc/libs/1_78_0/libs/math/doc/html/math_toolkit/factorials/sf_factorial.html|work=Boost 1.78.0 Documentation: Math Special Functions|access-date=2021-12-21}}</ref> 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|last1=Addis|first1=Tom|last2=Addis|first2=Jan|year=2009|url=https://books.google.com/books?id=cWM7ZBfEl_0C&pg=PA149|title=Drawing Programs: The Theory and Practice of Schematic Functional Programming|publisher=Springer|isbn=978-1-84882-618-2|pages=149–150}}</ref>
The computation of <math>n!</math> can be expressed in [[pseudocode]] using [[iteration]]<ref>{{cite book|last=Chapman|first=Stephen J.|year=2019|title=MATLAB Programming for Engineers|publisher=Cengage Learning|isbn=978-0-357-03052-3|edition=6th|page=215|contribution=Example 5.2: The factorial function|contribution-url=https://books.google.com/books?id=jVEzEAAAQBAJ&pg=PA215}}</ref> as {{bi|define factorial({{mvar|n}}):|left=1.6}} {{bi|1={{mvar|f}} := 1|left=3.2}} {{bi|1=for {{mvar|i}} := 1, 2, 3, ... {{mvar|n}}:|left=3.2}} {{bi|1={{mvar|f}} := {{mvar|f}} × {{mvar|i}}|left=4.8}} {{bi|return {{mvar|f}}|left=3.2}} or using [[Recursion (computer science)|recursion]]<ref>{{cite book|last1=Hey|first1=Tony|last2=Pápay|first2=Gyuri|year=2014|url=https://books.google.com/books?id=q4FIBQAAQBAJ&pg=PA64|title=The Computing Universe: A Journey through a Revolution|publisher=Cambridge University Press|isbn=9781316123225|page=64}}</ref> based on its recurrence relation as {{bi|define factorial({{mvar|n}}):|left=1.6}} {{bi|1=if {{mvar|n}} = 0 return 1|left=3.2}} {{bi|return {{mvar|n}} × factorial({{mvar|n}} − 1)|left=3.2}} Other methods suitable for its computation include [[memoization]],<ref>{{cite book|last=Bolboaca|first=Alexandru|year=2019|url=https://books.google.com/books?id=GwSgDwAAQBAJ&pg=PA188|title=Hands-On Functional Programming with C++: An effective guide to writing accelerated functional code using C++17 and C++20|publisher=Packt Publishing|isbn=978-1-78980-921-3|page=188}}</ref> [[dynamic programming]],<ref>{{cite book|last=Gray|first=John W.|year=2014|url=https://books.google.com/books?id=a4riBQAAQBAJ&pg=PA233|title=Mastering Mathematica: Programming Methods and Applications|publisher=Academic Press|isbn=978-1-4832-1403-0|pages=233–234}}</ref> and [[functional programming]].<ref>{{cite book|last=Torra|first=Vicenç|year=2016|url=https://books.google.com/books?id=eMwcDQAAQBAJ&pg=PA96|title=Scala From a Functional Programming Perspective: An Introduction to the Programming Language|publisher=Springer|isbn=978-3-319-46481-7|series=Lecture Notes in Computer Science|volume=9980|page=96}}</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|last=Sussman|first=Gerald Jay|year=1982|title=Functional Programming and Its Applications: An Advanced Course|publisher=Cambridge University Press|isbn=978-0-521-24503-6|series=CREST Advanced Courses|pages=29–72|contribution=LISP, programming, and implementation|author-link=Gerald Jay Sussman}} 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|title=Do the arithmetic operations really execute in constant time?|journal=ACM SIGCSE Bulletin|publisher=Association for Computing Machinery|volume=35|issue=2|pages=43–44|doi=10.1145/782941.782977|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]] integers.<ref name="sigplan">{{cite journal|last1=Winkler|first1=Jürgen F. H.|last2=Kauer|first2=Stefan|date=March 1997|title=Proving assertions is also useful|journal=ACM SIGPLAN Notices|publisher=Association for Computing Machinery|volume=32|issue=3|pages=38–41|doi=10.1145/251634.251638|s2cid=17347501}}</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]], and its time 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">{{cite journal|last=Borwein|first=Peter B.|author-link=Peter Borwein|year=1985|title=On the complexity of calculating factorials|journal=[[Journal of Algorithms]]|volume=6|issue=3|pages=376–380|doi=10.1016/0196-6774(85)90006-9|mr=800727}}</ref> 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|multiplication algorithms]] 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|year=2021|title=Integer multiplication in time <math>O(n \log n)</math>|url=https://hal.archives-ouvertes.fr/hal-02070778/file/nlogn.pdf|journal=[[Annals of Mathematics]]|series=Second Series|volume=193|issue=2|pages=563–617|doi=10.4007/annals.2021.193.2.4|mr=4224716|s2cid=109934776}}</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|year=2011|url=http://jjj.de/fxt/fxtbook.pdf|title=Matters Computational: Ideas, Algorithms, Source Code|publisher=Springer|pages=651–652|contribution=34.1.1.1: Computation of the factorial}} 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" /><ref name="schonhage">{{cite book|last=Schönhage|first=Arnold|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:
* 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 <math>n</math> is an <math>O(n)</math>-bit number, by the [[prime number theorem]], so the time for the first step is <math>O(n\log^2 n)</math>, 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]] {{nowrap|to <math>O(n\log^2 n)</math>.}} The time for the squaring in the second step and the multiplication in the third step are again {{nowrap|<math>O(n\log^2 n)</math>,}} because each is a single multiplication of a number with <math>O(n\log n)</math> 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 {{nowrap|to <math>O(n\log^2 n)</math>.}} Consequentially, the whole algorithm takes {{nowrap|time <math>O(n\log^2 n)</math>,}} proportional to a single multiplication with the same number of bits in its result.<ref name="schonhage" />
== Fungsi dan barisan yang berkaitan ==
{{main|Daftar topik faktorial dan binomial}}
Ada beberapa barisan bilangan bulat lainnya yang menyerupai atau berkaitan dengan faktorial:
; Fakatorial selang-seling
: The [[alternating factorial]] is the absolute value of the [[alternating sum]] of the first <math>n</math> factorials, {{nowrap|<math display=inline>\sum_{i = 1}^n (-1)^{n - i}i!</math>.}} 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.<ref>{{harvnb|Guy|2004}}. "B43: Alternating sums of factorials". pp. 152–153.</ref>
; Faktorial Bhargava
: The [[Bhargava factorial|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.<ref name="bhargava" />
; Faktorial ganda
: The product of all the odd integers up to some odd positive {{nowrap|integer <math>n</math>}} is called the [[double factorial]] {{nowrap|of <math>n</math>,}} and denoted by {{nowrap|<math>n!!</math>.<ref name="callan">{{cite arXiv|title=A combinatorial survey of identities for the double factorial|first=David|last=Callan|eprint=0906.1317|year=2009|class=math.CO}}</ref>}} That is, <math display="block">(2k-1)!! = \prod_{i=1}^k (2i-1) = \frac{(2k)!}{2^k k!}.</math> For example, {{nowrap|1=9!! = 1 × 3 × 5 × 7 × 9 = 945}}. Double factorials are used in [[List of integrals of trigonometric functions|trigonometric integrals]],<ref>{{cite journal|last=Meserve|first=B. E.|year=1948|title=Classroom Notes: Double Factorials|journal=[[The American Mathematical Monthly]]|volume=55|issue=7|pages=425–426|doi=10.2307/2306136|jstor=2306136|mr=1527019}}</ref> in expressions for the [[gamma function]] at [[Half-integer|half-integers]] and the [[Volume of an n-ball|volumes of hyperspheres]],<ref>{{cite journal|last=Mezey|first=Paul G.|year=2009|title=Some dimension problems in molecular databases|journal=Journal of Mathematical Chemistry|volume=45|issue=1|pages=1–6|doi=10.1007/s10910-008-9365-8|s2cid=120103389}}.</ref> and in counting [[Rooted binary tree|binary trees]] and [[Perfect matching|perfect matchings]].<ref name="callan" /><ref>{{cite journal|last1=Dale|first1=M. R. T.|last2=Moon|first2=J. W.|year=1993|title=The permuted analogues of three Catalan sets|journal=[[Journal of Statistical Planning and Inference]]|volume=34|issue=1|pages=75–87|doi=10.1016/0378-3758(93)90035-5|mr=1209991}}.</ref>
; Faktorial eksponensial
: Just as [[Triangular number|triangular numbers]] sum the numbers from <math>1</math> {{nowrap|to <math>n</math>,}} and factorials take their product, the [[exponential factorial]] exponentiates. The exponential factorial {{nowrap|of <math>n</math>,}} denoted {{nowrap|as <math>n\$</math>,}} is defined recursively {{nowrap|as <math>n^{(n-1)\$}</math>,}} with the base case {{nowrap|<math>0\$=1</math>.}} For example, <math display="block">4\$= 4^{3^{2^{1}}}=262144.</math> These numbers grow much more quickly than regular factorials.<ref>{{cite journal|last1=Luca|first1=Florian|last2=Marques|first2=Diego|year=2010|title=Perfect powers in the summatory function of the power tower|url=http://jtnb.cedram.org/item?id=JTNB_2010__22_3_703_0|journal=[[Journal de Théorie des Nombres de Bordeaux]]|volume=22|issue=3|pages=703–718|doi=10.5802/jtnb.740|mr=2769339|author1-link=Florian Luca}}</ref>
; Falling factorial
: The notations <math>(x)_{n}</math> or <math>x^{\underline n}</math> are sometimes used to represent the product of the <math>n</math> integers counting up to and {{nowrap|including <math>x</math>,}} equal to {{nowrap|<math>x!/(x-n)!</math>.}} This is also known as a [[Falling and rising factorials|falling factorial]] or backward factorial, and the <math>(x)_{n}</math> notation is a Pochhammer symbol.{{sfn|Graham|Knuth|Patashnik|1988|pp=x, 47–48}} Falling factorials count the number of different sequences of <math>n</math> distinct items that can be drawn from a universe of <math>x</math> items.<ref>{{cite book|last=Sagan|first=Bruce E.|year=2020|title=Combinatorics: the Art of Counting|location=Providence, Rhode Island|publisher=American Mathematical Society|isbn=978-1-4704-6032-7|series=Graduate Studies in Mathematics|volume=210|page=5|contribution=Theorem 1.2.1|mr=4249619|author-link=Bruce Sagan|contribution-url=https://books.google.com/books?id=DYgEEAAAQBAJ&pg=PA5}}</ref> They occur as coefficients in the [[Higher derivative|higher derivatives]] of polynomials,<ref>{{cite book|last=Hardy|first=G. H.|year=1921|title=A Course of Pure Mathematics|title-link=A Course of Pure Mathematics|publisher=Cambridge University Press|edition=3rd|page=215|contribution=Examples XLV|author-link=G. H. Hardy|contribution-url=https://archive.org/details/coursepuremath00hardrich/page/n229}}</ref> and in the [[Factorial moment|factorial moments]] of [[Random variable|random variables]].<ref>{{cite book|last1=Daley|first1=D. J.|last2=Vere-Jones|first2=D.|year=1988|title=An Introduction to the Theory of Point Processes|location=New York|publisher=Springer-Verlag|isbn=0-387-96666-8|series=Springer Series in Statistics|page=112|contribution=5.2: Factorial moments, cumulants, and generating function relations for discrete distributions|mr=950166|contribution-url=https://books.google.com/books?id=Af7lBwAAQBAJ&pg=PA112}}</ref>
; Hiperfaktorial
: The [[hyperfactorial]] of <math>n</math> is the product <math>1^1\cdot 2^2\cdots n^n</math>. These numbers form the [[Discriminant|discriminants]] of [[Hermite polynomials]].<ref>{{cite OEIS|A002109|2=Hyperfactorials: Product_{k = 1..n} k^k}}</ref> They can be continuously interpolated by the [[K-function]],<ref>{{cite journal|last=Kinkelin|first=H.|author-link=Hermann Kinkelin|year=1860|title=Ueber eine mit der Gammafunction verwandte Transcendente und deren Anwendung auf die Integralrechung|trans-title=On a transcendental variation of the gamma function and its application to the integral calculus|journal=[[Crelle's Journal | Journal für die reine und angewandte Mathematik]]|language=de|volume=1860|issue=57|pages=122–138|doi=10.1515/crll.1860.57.122|s2cid=120627417}}</ref> and obey analogues to Stirling's formula<ref>{{cite journal|last=Glaisher|first=J. W. L.|author-link=James Whitbread Lee Glaisher|year=1877|title=On the product {{math|1<sup>1</sup>.2<sup>2</sup>.3<sup>3</sup>...''n''<sup>''n''</sup>}}|url=https://archive.org/details/messengermathem01glaigoog/page/n56|journal=[[Messenger of Mathematics]]|volume=7|pages=43–47}}</ref> and Wilson's theorem.<ref>{{cite journal|last1=Aebi|first1=Christian|last2=Cairns|first2=Grant|year=2015|title=Generalizations of Wilson's theorem for double-, hyper-, sub- and superfactorials|journal=[[The American Mathematical Monthly]]|volume=122|issue=5|pages=433–443|doi=10.4169/amer.math.monthly.122.5.433|jstor=10.4169/amer.math.monthly.122.5.433|mr=3352802|s2cid=207521192}}</ref>
; Bilangan Jordan–Pólya
: The [[Jordan–Pólya number|Jordan–Pólya numbers]] are the products of factorials, allowing repetitions. Every [[Tree (graph theory)|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.<ref>{{cite OEIS|A001013|Jordan-Polya numbers: products of factorial numbers}}</ref>
; Primorial
: The [[primorial]] <math>n\#</math> is the product of [[Prime number|prime numbers]] less than or equal {{nowrap|to <math>n</math>;}} this construction gives them some similar divisibility properties to factorials,<ref name="caldwell-gallot2" /> but unlike factorials they are [[squarefree]].<ref>{{cite book|last=Nelson|first=Randolph|year=2020|url=https://books.google.com/books?id=m8PPDwAAQBAJ&pg=PA127|title=A Brief Journey in Discrete Mathematics|location=Cham|publisher=Springer|isbn=978-3-030-37861-5|page=127|doi=10.1007/978-3-030-37861-5|mr=4297795|s2cid=213895324}}</ref> As with the [[Factorial prime|factorial primes]] {{nowrap|<math>n!\pm 1</math>,}} researchers have studied [[Primorial prime|primorial primes]] {{nowrap|<math>n\#\pm 1</math>.<ref name=caldwell-gallot/>}}
; Subfaktorial
: The [[subfactorial]] yields the number of [[Derangement|derangements]] of a set of <math>n</math> objects. It is sometimes denoted <math>!n</math>, and equals the closest integer {{nowrap|to <math>n!/e</math>.{{sfn|Graham|Knuth|Patashnik|1988|p=195}}}}
; Superfaktorial
: 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|year=1900|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}|journal=[[The Quarterly Journal of Pure and Applied Mathematics]]|volume=31|pages=264–314|jfm=30.0389.02}}</ref>
== Referensi ==
|