Files
  • main.go
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
 
func isDivisibleBy5(num int) bool {
	return num % 5 == 0;
}

func isDivisibleBy3(num int) bool {
	return num % 3 == 0;
}

func isFizz(num int) bool {
	return isDivisibleBy3(num);
}

func isBuzz(num int) bool {
	return isDivisibleBy5(num);
}

func isFizzBuzz(num int) bool {
	return isFizz(num) && isBuzz(num);
}

func fizzBuzz(lowerBound int, upperBound int) {
	for i := lowerBound; i <= upperBound; i++ {
		println(i);
		
		if (isFizzBuzz(i)) {
			println("FizzBuzz!");
		} else if (isFizz(i)) {
			println("Fizz!");
		} else if (isBuzz(i)) {
			println("Buzz!");
		}
	}
}

func main() {
	var lowerBound = 1;
	var upperBound = 100;
	
	fizzBuzz(lowerBound, upperBound);
}