Your line
if (2^n)-1==find(prime(i));
is wrong. prime(i) is going to be a single non-zero value, and find() on a scalar non-zero value is going to return 1.
I suggest you change your test: take each prime, add 1, and determine whether the result is a power of 2.
Alternately, just go through the powers of 2 that are in the designated range, subtract 1, and test to see if the values are present in the list of primes you constructed.
Best Answer