Skip to content

Commit

Permalink
Merge pull request #1709 from zFz0000/patch-1
Browse files Browse the repository at this point in the history
golang fizzbuzz
  • Loading branch information
fineanmol authored Oct 1, 2022
2 parents 7d18192 + 2b46896 commit e33c2c4
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Program's_Contributed_By_Contributors/Golang Programs/fizzbuzz.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package main

import (
"fmt"
)

func main() {

fmt.Print("Enter integer: ")
var input int
fmt.Scanf("%d", &input)

for i := 1; i <= input; i++ {
fizzbuzz(i)
}
}

func fizzbuzz(i int) {
fizz := "fizz"
buzz := "buzz"

if i % 3 == 0 && i % 5 == 0 {
fmt.Println(i, fizz + buzz)
} else if i % 3 == 0 {
fmt.Println(i, fizz)
} else if i % 5 == 0 {
fmt.Println(i, buzz)
} else {
fmt.Println(i)
}
}

0 comments on commit e33c2c4

Please sign in to comment.