Lah numbers: Difference between revisions

Content added Content deleted
(added Tcl)
m (Improved C++ output)
Line 162: Line 162:
<lang cpp>// Reference: https://en.wikipedia.org/wiki/Lah_number#Identities_and_relations
<lang cpp>// Reference: https://en.wikipedia.org/wiki/Lah_number#Identities_and_relations


#include <cstdint>
#include <algorithm>
#include <iomanip>
#include <iomanip>
#include <iostream>
#include <iostream>
Line 192: Line 192:


void print_lah_numbers(unsigned_lah_numbers& uln, int n) {
void print_lah_numbers(unsigned_lah_numbers& uln, int n) {
std::cout << "Unsigned Lah numbers up to L(12,12):\nn/k";
for (int j = 1; j <= n; ++j)
std::cout << std::setw(11) << j;
std::cout << '\n';
for (int i = 1; i <= n; ++i) {
for (int i = 1; i <= n; ++i) {
std::cout << std::setw(2) << i << ' ';
for (int j = 1; j <= i; ++j)
for (int j = 1; j <= i; ++j)
std::cout << std::setw(11) << uln.get(i, j);
std::cout << std::setw(11) << uln.get(i, j);
Line 201: Line 206:
int main() {
int main() {
unsigned_lah_numbers uln;
unsigned_lah_numbers uln;
std::cout << "Unsigned Lah numbers up to L(12,12):\n";
print_lah_numbers(uln, 12);
print_lah_numbers(uln, 12);
std::cout << "Maximum value of L(n,k) where n == 100:\n";
std::cout << "Maximum value of L(n,k) where n == 100:\n";
integer max = 0;
integer max = 0;
for (int k = 0; k <= 100; ++k) {
for (int k = 0; k <= 100; ++k)
integer s = uln.get(100, k);
max = std::max(max, uln.get(100, k));
if (s > max)
max = s;
}
std::cout << max << '\n';
std::cout << max << '\n';
return 0;
return 0;
Line 217: Line 218:
<pre>
<pre>
Unsigned Lah numbers up to L(12,12):
Unsigned Lah numbers up to L(12,12):
n/k 1 2 3 4 5 6 7 8 9 10 11 12
1
2 1
1 1
6 6 1
2 2 1
24 36 12 1
3 6 6 1
120 240 120 20 1
4 24 36 12 1
720 1800 1200 300 30 1
5 120 240 120 20 1
5040 15120 12600 4200 630 42 1
6 720 1800 1200 300 30 1
40320 141120 141120 58800 11760 1176 56 1
7 5040 15120 12600 4200 630 42 1
362880 1451520 1693440 846720 211680 28224 2016 72 1
8 40320 141120 141120 58800 11760 1176 56 1
3628800 16329600 21772800 12700800 3810240 635040 60480 3240 90 1
9 362880 1451520 1693440 846720 211680 28224 2016 72 1
39916800 199584000 299376000 199584000 69854400 13970880 1663200 118800 4950 110 1
10 3628800 16329600 21772800 12700800 3810240 635040 60480 3240 90 1
479001600 2634508800 4390848000 3293136000 1317254400 307359360 43908480 3920400 217800 7260 132 1
11 39916800 199584000 299376000 199584000 69854400 13970880 1663200 118800 4950 110 1
12 479001600 2634508800 4390848000 3293136000 1317254400 307359360 43908480 3920400 217800 7260 132 1
Maximum value of L(n,k) where n == 100:
Maximum value of L(n,k) where n == 100:
44519005448993144810881324947684737529186447692709328597242209638906324913313742508392928375354932241404408343800007105650554669129521241784320000000000000000000000
44519005448993144810881324947684737529186447692709328597242209638906324913313742508392928375354932241404408343800007105650554669129521241784320000000000000000000000