Download or view PascalsTriangle.frink in plain text format
/** This solves the Rosetta Code problem "Pascal's triangle",
https://rosettacode.org/wiki/Pascal%27s_triangle
This is different from some other solutions in that it attempts to
automatically center the triangle based on the size of the numbers in the
lowest row.
*/
pascal[rows] :=
{
widest = length[toString[binomial[rows-1, (rows-1) div 2]]]
for row = 0 to rows-1
{
line = repeat[" ", round[(rows-row)* (widest+1)/2]]
for col = 0 to row
line = line + padRight[binomial[row, col], widest+1, " "]
println[line]
}
}
Download or view PascalsTriangle.frink in plain text format
This is a program written in the programming language Frink.
For more information, view the Frink
Documentation or see More Sample Frink Programs.
Alan Eliasen was born 20217 days, 23 hours, 35 minutes ago.