RosettaCodeData/Task/General-FizzBuzz/Ursa/general-fizzbuzz.ursa

42 lines
928 B
Plaintext

#
# general fizzbuzz
#
decl int<> factors
decl string<> words
decl int max
# get the max number
out ">" console
set max (in int console)
# get the factors
decl string input
set input " "
while (not (= input ""))
out ">" console
set input (in string console)
if (not (= input ""))
append (int (split input " ")<0>) factors
append (split input " ")<1> words
end if
end while
# output all the numbers
decl int i
for (set i 1) (< i (+ max 1)) (inc i)
decl boolean foundfactor
set foundfactor false
for (decl int j) (< j (size factors)) (inc j)
if (= (mod i factors<j>) 0)
set foundfactor true
out words<j> console
end if
end for
set j 0
if (not foundfactor)
out i console
end if
out endl console
end for