Difference between revisions of "Prime numbers assignment"
From WLCS
(Created page with "'''Objective:''' * To become well-learned in the way of the while loop '''Resources:''' * [http://openbookproject.net/thinkcs/python/english2e/ch06.html HTTLACS: Ch 6 - Iteratio...") |
|||
Line 11: | Line 11: | ||
# Use a loop that counts from 2 up to '''N/2''' | # Use a loop that counts from 2 up to '''N/2''' | ||
#* If N is divisible by the loop counter, then set '''isPrime''' to '''False''' | #* If N is divisible by the loop counter, then set '''isPrime''' to '''False''' | ||
− | # After the loop, check if '''isPrime''' is True, | + | # After the loop, check if '''isPrime''' is '''True''', |
+ | ## print out that it is a prime number, | ||
+ | ## else, print out that it is not a prime number |
Revision as of 14:10, 19 October 2012
Objective:
- To become well-learned in the way of the while loop
Resources:
Directions:
- Prompt the user to enter a number, N
- Create a variable named isPrime and set it to True
- Use a loop that counts from 2 up to N/2
- If N is divisible by the loop counter, then set isPrime to False
- After the loop, check if isPrime is True,
- print out that it is a prime number,
- else, print out that it is not a prime number