This preview shows page 1. Sign up to view the full content.
Unformatted text preview: g, finding prime numbers Idea can be applied to any problem you want to write code to solve We'll be looking at some well known algorithms for this later in the semester Algorithms Check if a user entered number is prime
Ask the user for a number to check the primeness of. Start with divisor equal to 2. If the user's number is divided evenly by the divisor, it is not prime. You are done. If the divisor squared is less than the user's number, increase it by one and go to step 3. If you've reached this step, the user's number is prime. 1. 2. 3. 4. 5. Algorithms Aspects of...
View Full Document
- Fall '11