I have this code in a function, but when it runs it does a long pause and then it says:
$floating point exception
I am assuming this is due to
Remember that the condition is for the loop to continue, not for it to end.
It's difficult to look at your code and see intuitively what you're trying to do. Although you could fix this by flipping some logic around (you meant (i < number && j != 1)
), it's best to stop and use break
inside the loop instead. The logic will be far clearer, and then you won't make errors like this.