def primetest(n):
if n<=1:
return false
"""Test if N is prime"""
for i in range(2,int(n/2)+1):
if(n%i)==0:
return false
return true
Hello so above I have my code that tells you if n is prime or not by returning true or false. Now I need to write a method called primelist()
which inputs a positive integer n and outputs an ordered list of primes 2 through p. Below I have added my code but when I go to test it, for example, I test primelist(7)==is_prime(7)
I get false but I should be getting true.
def primelist(n):
for i in range(2,n+1):
if primetest(i):
print(I,end=" ")