Jump to content

Pascal's triangle: Difference between revisions

added Fantom example
(added Fantom example)
Line 627:
<lang factor>5 pascal .
{ { 1 } { 1 1 } { 1 2 1 } { 1 3 3 1 } { 1 4 6 4 1 } }</lang>
 
=={{header|Fantom}}==
 
<lang fantom>
class Main
{
Int[] next_row (Int[] row)
{
new_row := [1]
(row.size-1).times |i|
{
new_row.add (row[i] + row[i+1])
}
new_row.add (1)
 
return new_row
}
 
Void print_pascal (Int n) // no output for n <= 0
{
current_row := [1]
n.times
{
echo (current_row.join(" "))
current_row = next_row (current_row)
}
}
 
Void main ()
{
print_pascal (10)
}
}
</lang>
 
=={{header|Forth}}==
342

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.