Question: Please use python to write the code. # write a program to check whether the each of the integers from 1 to 100 is prime,

Please use python to write the code.
# write a program to check whether the each of the integers from 1 to 100 is prime, and print out those that are # you should start by writing a function sprime that takes an integer, calculates all its factors, and returns # the value 1 if the only factors are 1 and the number itself, or 0 if it has other factors # then call t his function in a loop over the values 1,... ,100, and print out each number that is prime # hint: the code to find the factors of a number was given in the slides for module 4 # first define the sprime function # note this version includes 1 as a factor, and tests if the list of factors has length 2 # (i.e. the only factores are 1 and n, so the number is prime) at the end def isprime(n): # then test numbers from 1 to 100
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
