tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
29
Task/Pascals-triangle/Fantom/pascals-triangle.fantom
Normal file
29
Task/Pascals-triangle/Fantom/pascals-triangle.fantom
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
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)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue