Stirling numbers of the second kind: Difference between revisions
m
Improved C++ output
m (C bug fix) |
m (Improved C++ output) |
||
Line 211:
using integer = mpz_class;
class stirling2 {
public:
integer get(int n, int k);
Line 219 ⟶ 218:
};
integer stirling2::get(int n, int k) {
if (k == n)
return 1;
Line 234 ⟶ 232:
}
void print_stirling_numbers(stirling2& s2, int n) {
for (int
std::cout << std::setw(j == 0 ? 2 : 8) << j;
std::cout << '\n';
for (int i = 0; i <= n; ++i) {
std::cout << std::setw(2) << i << ' ';
for (int j = 0; j <= i; ++j)
std::cout << std::setw(j == 0 ? 2 : 8) << s2.get(i, j);
std::cout << '\n';
}
}
int main() {
stirling2 s2;
▲ std::cout << "Stirling numbers of the second kind:\n";
print_stirling_numbers(s2, 12);
std::cout << "Maximum value of S2(n,k) where n == 100:\n";
integer max = 0;
for (int k = 0; k <= 100; ++k)
▲ integer s = s2.get(100, k);
std::cout << max << '\n';
return 0;
Line 264 ⟶ 260:
<pre>
Stirling numbers of the second kind:
n/k 0 1 2 3 4 5 6 7 8 9 10 11 12
10 0
12 0 1 2047 86526 611501 1379400 1323652 627396 159027 22275 1705 66 1
Maximum value of S2(n,k) where n == 100:
7769730053598745155212806612787584787397878128370115840974992570102386086289805848025074822404843545178960761551674
|