what are the approaches to solve prime1 question
PRIME1
For solving this kind of question Sieve algorithms is one of the best way to solve
you can check my complete solution
first store all the prime numbers from 1 to 10^6 using sieve
And you have give that (n-m<=100000)
Then iterate all the numbers form n to m and use stored prime numbers for check the num is prime or not.
Example take n = 1234567 , m = 1235678
for num = 1234567 , check its a prime num or not for this iterate all the prime numbers upto < sqrt( 1234567) if any prime num divides 1234567 then its not prime , else prime num.
this is the link CodeChef: Practical coding for everyone of solution
a common method for this one, just go through this one.
https://www.youtube.com/watch?v=eKp56OLhoQs
for better undersatnding.
why have the guys upvoted this question? for upvotes?
yes u must be knowing better.