Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/FizzBuzz/Pyret/fizzbuzz.pyret
Normal file
18
Task/FizzBuzz/Pyret/fizzbuzz.pyret
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
fun fizzbuzz(n :: NumPositive) -> String:
|
||||
doc: ```For positive input which is multiples of three return 'Fizz', for the multiples of five return 'Buzz'.
|
||||
For numbers which are multiples of both three and five return 'FizzBuzz'. Otherwise, return the number itself.```
|
||||
ask:
|
||||
| num-modulo(n, 15) == 0 then: "FizzBuzz"
|
||||
| num-modulo(n, 3) == 0 then: "Fizz"
|
||||
| num-modulo(n, 5) == 0 then: "Buzz"
|
||||
| otherwise: num-to-string(n)
|
||||
end
|
||||
where:
|
||||
fizzbuzz(1) is "1"
|
||||
fizzbuzz(101) is "101"
|
||||
fizzbuzz(45) is "FizzBuzz"
|
||||
fizzbuzz(33) is "Fizz"
|
||||
fizzbuzz(25) is "Buzz"
|
||||
end
|
||||
|
||||
range(1, 101).map(fizzbuzz).each(print)
|
||||
Loading…
Add table
Add a link
Reference in a new issue