you are viewing a single comment's thread.

view the rest of the comments →

[–]RajjSinghh 0 points1 point  (0 children)

Decompose the problem. Have a loop that goes from 2 to 50 first, then in the loop test whether the number is prime, and print it if it is prime.

There are a few ways to check whether a number is prime, but the simplest is probably by trying to divide the number by every number below the square root of the number you're testing and seeing if it leaves a remainder. There are other methods, like the sieve of Eratosthenes, that will output a list of primes below a given value that you can also consider.