|
|
Let result be a Boolean variable. Return the result. |
If the number sent in is 0 or 1, set result to false Otherwise, if the number sent in is 2, set result to true Otherwise, if the number sent in is divisible by 2, set result to false |
Let limit be the integer (truncated) square root of the value sent in Loop from 3 through limit, incrementing by 2 |
true
, if that integer is a prime?
|
|
Otherwise (none of the above conditions has been met) Assume the number sent in is prime (result is true) Loop from 3 through limit, incrementing by 2 Check to see if the value sent in is divisible by the loop counter If it is, then Set result to false End the loop and return. |
Otherwise (is a synonym for 'else') Assume the number sent in is prime (Set result to true, you could do this on line 2) Let limit be the integer (truncated) square root of the value sent in (int limit = ...) LOOP counter from 3 through limit, incrementing by 2 (traditional 'for' loop) IF the value sent in is divisible by the loop counter THEN Set result to false End the loop and return. (use break;) END IF END LOOP END Otherwise Return the result. |