Java
UNIT CHALLENGES
CHALLENGE
·
Recall that a prime number is a
number that is only divisible by itself and by 1. ·
We can check if number n is
divisible by number d by using: ·
For n to be prime, we need to
check all numbers between 1 and n to see if they can divide n. So, we need to loop from 2 to n-1 (or from
n-1 down to 2). PSEUDOCODE |