I don't see anything wrong with your code, except that it could be more efficient. 9 is not a prime number as it is equal to 3 * 3. The output I get is:
2 is a prime number 3 is a prime number 4 equals 2 * 2 5 is a prime number 6 equals 2 * 3 7 is a prime number 8 equals 2 * 4 9 equals 3 * 3As indicated below the example in the link, the
else
belongs to the for
loop, NOT to the if
statement.