mirror of
https://github.com/bootdotdev/fcc-learn-golang-assets.git
synced 2025-12-17 10:41:17 +00:00
first
This commit is contained in:
23
course/7-loops/exercises/4-loops_fizzbuzz/complete.go
Normal file
23
course/7-loops/exercises/4-loops_fizzbuzz/complete.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func fizzbuzz() {
|
||||
for i := 1; i < 101; i++ {
|
||||
if i%3 == 0 && i%5 == 0 {
|
||||
fmt.Println("fizzbuzz")
|
||||
} else if i%3 == 0 {
|
||||
fmt.Println("fizz")
|
||||
} else if i%5 == 0 {
|
||||
fmt.Println("buzz")
|
||||
} else {
|
||||
fmt.Println(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// don't touch below this line
|
||||
|
||||
func main() {
|
||||
fizzbuzz()
|
||||
}
|
||||
Reference in New Issue
Block a user