How to make a function that appears only prime numbers?

how to make function that only prints out prime numbers?
im using PYTHON

I can’t really explain what I know about Python. I am learning basic algorithm problems of python.

You can however share the solution you have written if you want help with it.

#n is any number till which you want the prime numbers

import math
def prime_numer(cur_num):
    x = math.ceil(math.sqrt(cur_num))+1
    for i in range(2,x):
        if cur_num%i == 0:
            return False
    return True

n = 100
for i in range(2,n):
    if prime_numer(i):
        print(i)

thx lol
i might try it

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.