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