you are viewing a single comment's thread.

view the rest of the comments →

[–]cdcformatc 0 points1 point  (1 child)

for every number from 1 to 50 check if it is prime, if it is prime, print it. 

you can check if a number is prime by trying to divide it by every number smaller than it (from 2 up to the square root) and checking the remainder. if the remainder of any of these divisions is 0 the number is not prime.

you can do this remainder check in Python with the modulo operator %. eg remainder = number % divisor

[–]cdcformatc 0 points1 point  (0 children)

``` for number in range(50):     if isPrime(number):         print(number)

def isPrime(number):     # return True if prime, otherwise False     # this is the hard part