Catalan numbers/Pascal's triangle: Difference between revisions

m
→‎{{header|Zig}}: Correct stdout. Add hyperlink to AKS primality task. Comment on comptime const pascal.
(add RPL - fast, idiomatic)
m (→‎{{header|Zig}}: Correct stdout. Add hyperlink to AKS primality task. Comment on comptime const pascal.)
Line 2,346:
1 2 5 14 42 132 429 1430 4862 16796 58786 208012 742900 2674440 9694845 </pre>
=={{header|Zig}}==
Uses comptime functionality to compile Pascal's triangle into the object code, then at runtime, it's simply a table lookup. (uses code from [[AKS test for primes|AKS primality task]].)
<syntaxhighlight lang="zig">
const std = @import("std");
const stdout = std.io.getStdOut().outStream();
 
pub fn main() !void {
const stdout = std.io.getStdOut().outStreamwriter();
 
var n: u32 = 1;
while (n <= 15) : (n += 1) {
Line 2,370 ⟶ 2,371:
const rmax = 68;
 
// evaluated and created at compile-time
const pascal = build: {
@setEvalBranchQuota(100_000);
Line 2,409 ⟶ 2,411:
15 9694845
</pre>
 
=={{header|zkl}}==
{{trans|PARI/GP}} using binomial coefficients.
59

edits