Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
41
Task/General-FizzBuzz/Ursa/general-fizzbuzz.ursa
Normal file
41
Task/General-FizzBuzz/Ursa/general-fizzbuzz.ursa
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#
|
||||
# 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue