fizzbuzz.cmn 547 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # famous fizzbuzz program
  2. printNum: # prints number <= 100
  3. $0 100 = ?
  4. ^
  5. 0 "100" -->
  6. !.
  7. .
  8. $0 10 >= ?
  9. $0 10 / "0" + ->
  10. 10 %
  11. .
  12. "0" + ->
  13. .
  14. 1 # i (counter)
  15. @@
  16. $0 100 > ?
  17. !@
  18. .
  19. $0 1 != ? # print comma before every but first number
  20. "," -> " " ->
  21. .
  22. $0 3 % 0 = $1 5 % 0 = 2 * | # (i % 3 == 0) | ((i % 5 == 0) << 1)
  23. $0 0 = ?
  24. $1 printNum
  25. ;
  26. $0 1 & ?
  27. 0 "Fizz" -->
  28. .
  29. $0 3 = ?
  30. " " ->
  31. .
  32. $0 2 & ?
  33. 0 "Buzz" -->
  34. .
  35. .
  36. ^
  37. ++
  38. .
  39. ^