Playing with Cards(in Stack)

2 out of 3 test cases giving wrong answer. However all the kind of inputs are giving the right answer. Pls suggest the changes which I need to make.

coding blocks ide- https://ide.codingblocks.com/s/190307

Please provide your code in Coding Blocks IDE

1 Like

@dakshguptajune sorry for the delay.
Your method to find prime i wrong, it is not returning the correct prime number it is just returning odd numbers.
I have updated your code for finding prime numbers using sieve of Eratosthenes, also instead of calculating primes again and again you can calculate all primes at once and store them in array.

If this resolves your doubt mark it as resolved.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.