Check the prime number using for ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Check the prime number using for ?

To find all the prime numbers to a given number. Prime number ? What is code ?

1st Jan 2023, 5:23 AM
Selva Neyas U
Selva Neyas U - avatar
2 Answers
0
What exactly are you asking? If you’re asking what a prime number is, it’s any integer greater than 1 which is divisible only by one and itself. There are infinite prime numbers beginning with: 2, 3, 5, 7, 11, 13, 17, 19, 23… One simple algorithm for finding all primes less than n is the Sieve of Eratosthenes. My implementation here is in C, but you can find more information on Wikipedia if you don’t have experience with C—the algorithm is famous. https://code.sololearn.com/cxCZ368BeI0J/?ref=app
1st Jan 2023, 6:46 AM
Jeremy Miller
0
Hint: use Modulo operator. Workout your brain!
1st Jan 2023, 1:56 PM
iTech
iTech - avatar