Triangular numbers: Difference between revisions
Content added Content deleted
(julia example) |
m (→{{header|Julia}}: spacing) |
||
Line 81: | Line 81: | ||
polytopic(r, range) = map(n -> binomial(n + r - 1, r), range) |
polytopic(r, range) = map(n -> binomial(n + r - 1, r), range) |
||
triangular_root(x) = |
triangular_root(x) = (sqrt(8x + 1) - 1) / 2 |
||
function tetrahedral_root(x) |
function tetrahedral_root(x) |
||
Line 100: | Line 100: | ||
for n in [7140, 21408696, 26728085384, 14545501785001] |
for n in [7140, 21408696, 26728085384, 14545501785001] |
||
println("\nRoots of $n:") |
println("\nRoots of $n:") |
||
println(" triangular-root: ", triangular_root(n)) |
println(" triangular-root: ", triangular_root(n)) |
||
println(" tetrahedral-root: ", tetrahedral_root(n)) |
println(" tetrahedral-root: ", tetrahedral_root(n)) |
||
println(" pentatopic-root: ", pentatopic_root(n)) |
println(" pentatopic-root: ", pentatopic_root(n)) |
||
end |
end |
||
</syntaxhighlight>{{out}} |
</syntaxhighlight>{{out}} |