I am using the sieve of sundaram to get an array of primes upto 4000 and then doing binary search on it to find the next greatest prime then the sum of X and Y and outputting the different between the prime and the sum. but it gives me wrong answer.

help?

link to my code