September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
18
Task/FizzBuzz/Dc/fizzbuzz-2.dc
Normal file
18
Task/FizzBuzz/Dc/fizzbuzz-2.dc
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# dc is stack based, so we use the stack instead of a variable for our
|
||||
# current number.
|
||||
|
||||
1 # Number = 1
|
||||
[[Fizz]n 1 sw]sF # Prints "Fizz" prevents Number from printing
|
||||
[[Buzz]n 1 sw]sB # Prints "Buzz" prevents Number from printing
|
||||
[dn]sN # Prints Number
|
||||
[
|
||||
dd # Put two extra copies of Number on stack
|
||||
0 sw # w = 0
|
||||
3% 0=F # Fizz if 0 == Number % 3 (destroys 1st copy)
|
||||
5% 0=B # Buzz if 0 == Number % 5 (destroys 2nd copy)
|
||||
lw 0=N # Print Number if 0 == w
|
||||
[
|
||||
]n # Print new line
|
||||
1+d # Number += 1 and put extra copy on stack
|
||||
100!<L # Continue Loop if 100 >= Number (destroys copy)
|
||||
]dsLx # Enter Loop
|
||||
Loading…
Add table
Add a link
Reference in a new issue