我正在使用Swift创建一个简单的Fizz Buzz Generator。
我收到以下错误:
Playground execution failed: <EXPR>:15:33: error: type 'Int' does not conform to protocol 'BooleanType'
} else if (number % 3 == 0) && (number % 5) {
这就是我所拥有的:
for number in 1...100 {
if (number % 3 == 0) {
println("Fizz")
} else if (number % 5 == 0) {
println("Buzz")
} else if (number % 3 == 0) && (number % 5) {
println("Fizz Buzz")
} else {
println(number)
}
}
答案 0 :(得分:3)
你错过了一些逻辑。变化
else if (number % 3 == 0) && (number % 5)
到
else if (number % 3 == 0) && (number % 5 == 0)