Question: use 3 6 Version 1 for each number n from 2 to the given number: set isPrime to true for each number m from 2

use 36 Version1
for each number n from 2 to the given number:
set isPrime to true
for each number m from 2 to n-1:
if n is divisible by m:
set isPrime to false
break
if isPrime is true:
print n
Version 2
for each number n from 2 to the given number:
set isPrime to true
for each number m from 2 to the square root of n:
if n is divisible by m:
set isPrime to false
break
if isPrime is true:
print n
Version 3
print 2
for each odd number n from 3 to the given number:
set isPrime to true
for each odd number m from 3 to the square root of n:
if n is divisible by m:
set isPrime to false
break
if isPrime is true:
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!