tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
11
Task/Pascals-triangle/Forth/pascals-triangle-1.fth
Normal file
11
Task/Pascals-triangle/Forth/pascals-triangle-1.fth
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
: init ( n -- )
|
||||
here swap cells erase 1 here ! ;
|
||||
: .line ( n -- )
|
||||
cr here swap 0 do dup @ . cell+ loop drop ;
|
||||
: next ( n -- )
|
||||
here swap 1- cells here + do
|
||||
i @ i cell+ +!
|
||||
-1 cells +loop ;
|
||||
: pascal ( n -- )
|
||||
dup init 1 .line
|
||||
1 ?do i next i 1+ .line loop ;
|
||||
8
Task/Pascals-triangle/Forth/pascals-triangle-2.fth
Normal file
8
Task/Pascals-triangle/Forth/pascals-triangle-2.fth
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
: PascTriangle
|
||||
cr dup 0
|
||||
?do
|
||||
1 over 1- i - 2* spaces i 1+ 0 ?do dup 4 .r j i - * i 1+ / loop cr drop
|
||||
loop drop
|
||||
;
|
||||
|
||||
13 PascTriangle
|
||||
Loading…
Add table
Add a link
Reference in a new issue