There are quitequite aa largelarge numbernumber ofof existingexisting implementatonsimplementatons ofof FizzBuzzFizzBuzz but I awoke this morning in a cold sweat with the terrible revelation that Code Review had no FizzBuzz implementation in Forth! To redress this terrible oversight, I wrote this while sipping my first cup of coffee.
: FIZZBUZZ ( -- )
CR 100 1 DO
I 3 MOD 0= I 5 MOD 0= 2DUP AND IF
." fizzbuzz " DROP DROP
ELSE IF
." buzz " DROP
ELSE IF
." fizz "
ELSE I . THEN THEN THEN
LOOP ;
I'm interested in a general review, including possible alternatives to the use of MOD, and whether further factoring should be used.
For those unfamiliar with Forth, try http://www.forth.org/tutorials.html