1 ! Copyright (c) 2012 Anonymous
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: io kernel math math.functions math.parser ranges
5 IN: rosetta-code.fizzbuzz
7 : fizz ( n -- str ) 3 divisor? "Fizz" "" ? ;
9 : buzz ( n -- str ) 5 divisor? "Buzz" "" ? ;
11 : fizzbuzz ( n -- str )
12 dup [ fizz ] [ buzz ] bi append [ number>string ] [ nip ] if-empty ;
14 : fizzbuzz-main ( -- )
15 100 [1..b] [ fizzbuzz print ] each ;