4 Answers
+ 5
You use a counter/flag and check for remainders with each number less than that number and if the remainder is 0, you have a factor. So, that number isn't a prime number.
Thus, for whichever number the flag remains off, or the counter 0, that numbers would be prime.
John Championđ€đ„ Try it out yourself. If you need more help, feel free to ask.
Guezi Louay I don't think you should give away the code right away. You should just let them off with some hints so that they could practice and learn. Getting the answer is never the solution, the process matters.
+ 2
Kainatic ..Thank you so much
Your reply was more like a normal personâ€ïž
+ 1
hereâs my way of finding a certain amount of primes, itâs not the shortest code, but i wanted to make it as efficiĂ«nt as i could so yeah.. i just try to devide a number by all the primes that are smaller than that number and if the outcome is never 0 itâs a prime and than i just test the next number...
https://code.sololearn.com/cXP80RNTKJOs/?ref=app