Last active
February 2, 2018 20:39
-
-
Save chandler767/c818cc3c715dd9c9c48cfd24b1835a1d to your computer and use it in GitHub Desktop.
Write a program that prints numbers from 1 to N. But for multiples of three print “Fizz” instead of the number, and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz".
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
n := 15 | |
for i:=1; i<=n; 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) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment