I am trying to learn Python programming, and I'm pretty new at this.
I was having issues in printing a series of prime numbers from one to hundred. I can't figure our what's wrong with my code.
Here's what I wrote; it prints all the odd numbers instead of primes:
for num in range(1,101):
for i in range(2,num):
if (num%i==0):
break
else:
print(num)
break
I was inspired by Igor and made a code block that creates a list:
we can make a list of prime numbers using sympy library
Here is a simplified answer using lambda function.
Here is a different approach that trades space for faster search time. This may be fastest so.