mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
examples: cleanup examples/fizz_buzz.v
This commit is contained in:
parent
5a752c9a2d
commit
49aa602fe5
1 changed files with 7 additions and 16 deletions
|
@ -1,17 +1,8 @@
|
|||
fn main() {
|
||||
mut s := ''
|
||||
for n in 1 .. 101 {
|
||||
if n % 3 == 0 {
|
||||
s += 'Fizz'
|
||||
}
|
||||
if n % 5 == 0 {
|
||||
s += 'Buzz'
|
||||
}
|
||||
if s == '' {
|
||||
println(n)
|
||||
} else {
|
||||
println(s)
|
||||
}
|
||||
s = ''
|
||||
}
|
||||
for n in 1 .. 101 {
|
||||
println(match true {
|
||||
n % 15 == 0 { 'FizzBuzz' }
|
||||
n % 5 == 0 { 'Buzz' }
|
||||
n % 3 == 0 { 'Fizz' }
|
||||
else { n.str() }
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue