Floyd's triangle: Difference between revisions
Content added Content deleted
Line 2,716: | Line 2,716: | ||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
<lang julia>function floydtriangle(rows) |
<lang julia>function floydtriangle(rows) |
||
r = collect(1:div(rows *(rows + 1), 2)) |
|||
spacing = Int(ceil(log10(r[end] + 1))) + 1 |
|||
⚫ | |||
for i in 1:rows |
|||
⚫ | |||
print(lpad(popfirst!(r), spacing)) |
|||
end |
|||
⚫ | |||
println() |
|||
⚫ | |||
end |
|||
end |
end |
||
floydtriangle(5) |
floydtriangle(5); println(); floydtriangle(14) |
||
floydtriangle(14) |
|||
</lang>{{out}} |
</lang>{{out}} |
||
<pre> |
<pre> |
||
1 |
|||
2 3 |
|||
4 5 6 |
|||
7 8 9 10 |
|||
11 12 13 14 15 |
|||
1 |
1 |
||
2 3 |
2 3 |