Print series of prime numbers in python
问题 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 回答1: You need to check all numbers from 2 to n-1 (to sqrt(n) actually, but ok, let it be n). If n is divisible by any of the numbers, it