I am trying to do the challenge without being clever and looping from 2 to number instead of using the square root to number and it is returning false for every number. I can’t figure out what is wrong. The isNumberDivisible function is returning the correct value when I execute it on it’s own. Here is my code. I’d really appreciate the help.
func isNumberDivisible(number: Int, by byNumber: Int) -> Bool {
return number % byNumber == 0
}
func isPrime(number: Int) -> Bool {
if number < 2 {
return false
}
for i in 2...number {
if isNumberDivisible(number, by: i) {
return false
}
}
return true
}