diff --git a/13_exercise-solutions/07_threeFive/main.go b/13_exercise-solutions/07_threeFive/main.go index eaacdadc..8be90787 100644 --- a/13_exercise-solutions/07_threeFive/main.go +++ b/13_exercise-solutions/07_threeFive/main.go @@ -5,15 +5,14 @@ import "fmt" func main() { counter := 0 for i := 0; i < 1000; i++ { - if i%3 == 0 { - counter += i - } else if i%5 == 0 { + if i%3 == 0 || i%5 == 0 { counter += i } } fmt.Println(counter) } + /* If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9.