Question: Python (Idle 3.6) Write a program to show all prime numbers between 3 - 100. Prime number can only be evenly (remainder 0) divided by

Python (Idle 3.6)

Write a program to show all prime numbers between 3 - 100.

Prime number can only be evenly (remainder 0) divided by itself

Example of PRIME NUMBER testing: 4 -> 4 : 2 = 2.0 , 4 is NOT a prime (because there is a Zero after the decimal) 5 -> 5 : 2 = 2.5 ; 5 : 3 = 1.67 ; 5 : 4 = 1.25, 5 is A PRIME (no Zeroafter decimal) 6 -> 6 : 2 = 3.0 , 6 is NOT a prime (because there is a Zero after the decimal) 7 -> 7 : 2 = 3.5; 7 : 3 = 2.33; 7 : 4 = 1.75; 7 : 5 = 1.4; 7 : 6 = 1.17 7 is A PRIME (no Zero after decimal)

HINTS: You'll need: 1) 1st Loop to make the numbers, N: between 3 to 100 2) 2nd Loop nested(inside) in the 1st loop to make numbers J: between 2 to N - 1 3) Two IF's inside the 2nd Loop

3a) if N % J == 0, then N is not a prime.

BREAK the 2nd Loop. Breaking the 2nd loop means go to the next N in the 1st loop

3b) if N % J != 0 for all J's , then N is a prime, so print(N)

(I) You have checked all J's if you are at the end of the 2nd loop.

(II) You are at the end of the 2nd loop when J == N - 1.

(III) So if N%J != 0 AND J == N - 1 , then print(N)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!