← Back to Loops
Question 402
Primes In A List
Primes In A List
Five whole numbers are read into a list. Print only the prime ones, each on its own line and in their original order. This is the second half of a matching pair with the evens question: the outer for loop has the same shape, but the test for one candidate is itself a loop. Start a divisor at 2 and use an inner while loop that runs while the divisor is below the candidate, clearing a flag whenever the remainder operator % gives 0 for that divisor; a candidate below 2 is never prime. Input: five integers, one per line, no prompts.
Expected Output:
7 13 2
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
LoopsPractice Problems
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.