chandler767
2/2/2018 - 8:39 PM

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 fiv

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".

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)
    }
  }
}