Task

Write a program that prints the integers from   1   to   100   (inclusive).



But:

   for multiples of three,   print   Fizz     (instead of the number)
   for multiples of five,   print   Buzz     (instead of the number)
   for multiples of both three and five,   print   FizzBuzz     (instead of the number) 


The   FizzBuzz   problem was presented as the lowest level of comprehension required to illustrate adequacy.



Also see

   (a blog)   dont-overthink-fizzbuzz
   (a blog)   fizzbuzz-the-programmers-stairway-to-heaven


 
with: n
 
: num?  \ n f --   ) 
	if drop else . then ;
 
\ is m mod n 0? leave the result twice on the stack
: div? \ m n -- f f
	mod 0 = dup ;
 
: fizz? \ n -- n f
	dup 3 
	div? if "Fizz" .  then ;
 
: buzz? \ n f -- n f
	over 5 
	div? if "Buzz" .  then or ;
 
\ print a message as appropriate for the given number:
: fizzbuzz  \ n --
	fizz? buzz? num? 
	space ;
 
\ iterate from 1 to 100:
' fizzbuzz 1 100 loop 
cr bye
 