How Do you get a series of prime number in python? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 3

How Do you get a series of prime number in python?

Python

14th May 2019, 11:21 PM
Troy🌹
Troy🌹 - avatar
4 Réponses
+ 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.
15th May 2019, 10:57 PM
Kainatic [Mostly Inactive Now]
Kainatic [Mostly Inactive Now] - avatar
+ 2
Check this! Better you search first then ask 😙: https://code.sololearn.com/czMY8Sa1D30q/?ref=app
14th May 2019, 11:48 PM
Guezi Louay
Guezi Louay - avatar
+ 2
Kainatic ..Thank you so much Your reply was more like a normal person❤️
15th May 2019, 10:59 PM
Troy🌹
Troy🌹 - avatar
+ 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
13th Jun 2019, 8:52 PM
Max Poppe
Max Poppe - avatar