Created
April 12, 2015 18:53
-
-
Save cdnsteve/003ad45ba64fb8e6f38e to your computer and use it in GitHub Desktop.
Fizz Buzz example using Go Lang
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
// Copyright 2015 Steven Leggett. All rights reserved. | |
package main | |
import "fmt" | |
func main() { | |
const ( | |
x string = "Go Lang Fizz Buzz" | |
v string = "1.0.0" | |
) | |
fmt.Println(x, v) | |
i := 1 | |
for i <= 100 { | |
if i%3 == 0 && i%5 == 0 { | |
fmt.Println(i, "FizzBuzz") | |
} else if i%3 == 0 { | |
fmt.Println(i, "Fizz") | |
} else if i%5 == 0 { | |
fmt.Println(i, "Buzz") | |
} else { | |
fmt.Println(i) | |
} | |
i = i + 1 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment