Chapter 7 Challenge A isPrime always returning false

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
}

... is called the closed range operator. It’s a sequence of values from the left hand value to the right hand value, including both of those values. So, for example, the values in the range 2...2 are [2]. So i will be assigned the value 2, and your code will call isNumberDivisible(2, by: 2), which will return true. Prime numbers are divisible by themselves; you need to exclude the prime number itself from your range of values.

Thanks for your help. When I replaced the closed range with a half-open range it works.

Cheers

Sinead