ok. Got it to work for 1 to 7. The issue was that I was filling the primesArray with primes less than max. But it should be at least max*2 (Because 7+6 is 13.  13 is a prime but it is not included in the primesArray as I originally calculated primes till 7). But it seems to fail for 71. So trying to figure out why