Jump to content

Lah numbers: Difference between revisions

m
Improved C++ output
(added Tcl)
m (Improved C++ output)
Line 162:
<lang cpp>// Reference: https://en.wikipedia.org/wiki/Lah_number#Identities_and_relations
 
#include <cstdintalgorithm>
#include <iomanip>
#include <iostream>
Line 192:
 
void print_lah_numbers(unsigned_lah_numbers& uln, int n) {
std::cout << "Unsigned Lah numbers up to L(12,12):\nnn/k";
for (int j = 1; j <= n; ++j)
std::cout << std::setw(11) << j;
std::cout << '\n';
for (int i = 1; i <= n; ++i) {
std::cout << std::setw(2) << i << ' ';
for (int j = 1; j <= i; ++j)
std::cout << std::setw(11) << uln.get(i, j);
Line 201 ⟶ 206:
int main() {
unsigned_lah_numbers uln;
std::cout << "Unsigned Lah numbers up to L(12,12):\n";
print_lah_numbers(uln, 12);
std::cout << "Maximum value of L(n,k) where n == 100:\n";
integer max = 0;
for (int k = 0; k <= 100; ++k) {
integer smax = std::max(max, uln.get(100, k));
if (s > max)
max = s;
}
std::cout << max << '\n';
return 0;
Line 217 ⟶ 218:
<pre>
Unsigned Lah numbers up to L(12,12):
n/k 1 2 3 4 5 6 7 8 9 10 11 12
1
1 2 1
2 6 62 1
3 24 6 36 126 1
4 120 24 240 36 120 2012 1
5 720 120 1800 240 1200 120 300 3020 1
6 5040 720 15120 1800 12600 1200 4200 300 630 4230 1
7 40320 5040 141120 15120 141120 12600 58800 4200 11760 1176630 5642 1
8 362880 40320 1451520 141120 1693440 141120 846720 21168058800 2822411760 20161176 7256 1
9 3628800 362880 16329600 217728001451520 12700800 1693440 3810240 846720 635040 211680 60480 28224 3240 2016 90 72 1
10 39916800 1995840003628800 299376000 16329600 199584000 21772800 69854400 12700800 13970880 3810240 1663200 635040 118800 60480 4950 3240 110 90 1
11 479001600 2634508800 439084800039916800 3293136000 1317254400199584000 307359360299376000 199584000 43908480 69854400 3920400 13970880 2178001663200 118800 7260 4950 132 110 1
12 479001600 2634508800 4390848000 3293136000 1317254400 307359360 43908480 3920400 217800 7260 132 1
Maximum value of L(n,k) where n == 100:
44519005448993144810881324947684737529186447692709328597242209638906324913313742508392928375354932241404408343800007105650554669129521241784320000000000000000000000
1,777

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.