I am trying to check if a number is a multiple of 3 or 5 or both in which different vaues would be printed. I am able to get the values running but checking for both does not seem to give the expected result.
here is my code and response
func fizzBuzz(n: Int) -> Void {
let value = n
for i in 1...value{
if(i.isMultiple(of: 5)){
print("Buzz")
} else if(i.isMultiple(of: 3)){
print("Fizz")
} else if (i.isMultiple(of: 5)) && (i.isMultiple(of: 3)){
return print("FizzBuzz")
} else {
print(i)
}
}
}
fizzBuzz(n: 15)
the response
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
Buzz