+ 3
Prime number in C++?
If i have range of values that I need to check if it prime or not? What can i do ;(!!
12 Answers
+ 9
@@Latifah Almulhim
ohh sorry
😊😊
+ 8
check this java version i think you like!!
https://code.sololearn.com/c8KCZTNWXzC8/?ref=app
+ 8
@@Latifah Almulhim,
welcome
+ 8
Latifah Almulhim
welcome!!
👍👍
+ 7
@@Latifah Almulhim,
enter any number and check the output if you find help full then i will convert this program into c or c++ any language that you prefer
+ 5
You should check out the sieve of Eratosthenes for prime numbers. There are plenty of codes out in the public for using this method. Good luck!
+ 4
step 1: create a function which accepts a number and returns a boolean statement (true, false)
step 2: create a for loop which increments the starting point until it reaches the end of the range
step 3: place the function call inside the loop and feed the iterator of the loop into it
if it outputs true -> prime -> print iterator
if it outputs false -> no prime
If you need help with a step feel free to ask again. But I won't give a complete solution :P
+ 3
Thank you all
+ 1
check this...
https://code.sololearn.com/cwjCjd5K0xD8/?ref=app
+ 1
I didn’t learn Java yet. 😅
+ 1
Now I know how to make program for prime numbers . I upload the code.
+ 1
@Asif Bilakhiya Thanks 🙏🏻