how to make function that only prints out prime numbers?
im using PYTHON
Firstly, welcome to the forums.
While we are primarily here to help people with their Free Code Camp progress, we are open to people on other paths, too.
With your current questions, we don’t have enough context to know what you already know or don’t know, so it is impossible to guide you without just telling you the answer (which we won’t do).
It is pretty typical on here for people to share a codepen / repl.it / jsfiddle example of what they have tried so that anyone helping has more of an idea of what help is actually helpful.
Please provide some example of what you’ve tried and I’m sure you’ll get more help.
Happy coding
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