hey,can u see the error in my code.
Prime visit(prime number between two numbers)
@Sumant123,
I have attached the code below. Kindly complete the visit function using the Sieve of Eratosthenes method. Also, the approach you’ve used is incorrect for finding the primes. As I told you in your previous post you have to use Sieve of Eratosthenes and compute all prime numbers before hand.
I am attaching a code which I have edited and you just need to write the code for Sieve of Eratosthenes.
What is sieve?
Start from the first prime number i.e. 2. Take its square(4) and increment it by the number you took (i.e. 4,6,8,10 and so on). Mark all these as 1 since they cannot be primes.
Now take the next unmarked number, 3. And mark 9,12,15 and so as 1. Similarly do it for 4. 16,20,24 and so on as 1.
Now at the end, all primes will be marked as 0 and all non primes will be 1.
The approach you have used is not the best approach to find prime numbers in a range.