2023-10-06 12:17:37 +00:00
|
|
|
fizzbuzz_basic = function <limit> {
|
|
|
|
count = 1
|
|
|
|
|
2023-10-07 01:59:01 +00:00
|
|
|
while count < limit {
|
2023-10-06 12:17:37 +00:00
|
|
|
if count % 3 == 0 && count % 5 == 0 {
|
2023-10-07 01:59:01 +00:00
|
|
|
(output 'fizzbuzz')
|
|
|
|
} else f count % 3 == 0 {
|
|
|
|
(output 'fizz')
|
|
|
|
} else if count % 5 == 0 {
|
|
|
|
(output 'buzz')
|
|
|
|
} else
|
|
|
|
(output count)
|
|
|
|
|
|
|
|
count += 1
|
2023-10-06 12:17:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fizzbuzz_match <limit> {
|
|
|
|
count = 1
|
|
|
|
|
|
|
|
while count < 1 {
|
|
|
|
output match [count % 3 == 0, count % 5 == 0] {
|
|
|
|
[true, false] => 'fizz'
|
|
|
|
[false, true] => 'buzz'
|
|
|
|
[true, true] => 'fizzbuzz'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fizzbuzz_basic<15>
|
|
|
|
fizzbuzz_match<15>
|