|
2 | 2 |
|
3 | 3 | # Factorials
|
4 | 4 |
|
5 |
| -const _fact_table64 = |
6 |
| - Int64[1,2,6,24,120,720,5040,40320,362880,3628800,39916800,479001600,6227020800, |
7 |
| - 87178291200,1307674368000,20922789888000,355687428096000,6402373705728000, |
8 |
| - 121645100408832000,2432902008176640000] |
9 |
| - |
10 |
| -const _fact_table128 = |
11 |
| - UInt128[0x00000000000000000000000000000001, 0x00000000000000000000000000000002, |
12 |
| - 0x00000000000000000000000000000006, 0x00000000000000000000000000000018, |
13 |
| - 0x00000000000000000000000000000078, 0x000000000000000000000000000002d0, |
14 |
| - 0x000000000000000000000000000013b0, 0x00000000000000000000000000009d80, |
15 |
| - 0x00000000000000000000000000058980, 0x00000000000000000000000000375f00, |
16 |
| - 0x00000000000000000000000002611500, 0x0000000000000000000000001c8cfc00, |
17 |
| - 0x0000000000000000000000017328cc00, 0x0000000000000000000000144c3b2800, |
18 |
| - 0x00000000000000000000013077775800, 0x00000000000000000000130777758000, |
19 |
| - 0x00000000000000000001437eeecd8000, 0x00000000000000000016beecca730000, |
20 |
| - 0x000000000000000001b02b9306890000, 0x000000000000000021c3677c82b40000, |
21 |
| - 0x0000000000000002c5077d36b8c40000, 0x000000000000003ceea4c2b3e0d80000, |
22 |
| - 0x000000000000057970cd7e2933680000, 0x00000000000083629343d3dcd1c00000, |
23 |
| - 0x00000000000cd4a0619fb0907bc00000, 0x00000000014d9849ea37eeac91800000, |
24 |
| - 0x00000000232f0fcbb3e62c3358800000, 0x00000003d925ba47ad2cd59dae000000, |
25 |
| - 0x0000006f99461a1e9e1432dcb6000000, 0x00000d13f6370f96865df5dd54000000, |
26 |
| - 0x0001956ad0aae33a4560c5cd2c000000, 0x0032ad5a155c6748ac18b9a580000000, |
27 |
| - 0x0688589cc0e9505e2f2fee5580000000, 0xde1bc4d19efcac82445da75b00000000] |
| 5 | +const _fact_table64 = Vector{Int64}(20) |
| 6 | +_fact_table64[1] = 1 |
| 7 | +for n in 2:20 |
| 8 | + _fact_table64[n] = _fact_table64[n-1] * n |
| 9 | +end |
| 10 | + |
| 11 | +const _fact_table128 = Vector{UInt128}(34) |
| 12 | +_fact_table128[1] = 1 |
| 13 | +for n in 2:34 |
| 14 | + _fact_table128[n] = _fact_table128[n-1] * n |
| 15 | +end |
28 | 16 |
|
29 | 17 | function factorial_lookup(n::Integer, table, lim)
|
30 | 18 | n < 0 && throw(DomainError())
|
|
0 commit comments