I am trying to solve a project euler prob 26 solution. I stumbled across a link that uses python to solve it. Here is the code snippet:
The IsPrime function is different which does not seem to cause any issues.
n = 997 #starting prime closest to limit
for p in range(n, 1 ,-2):
if not is_prime(p): continue
c = 1
while (pow(10, c) - 1) % p != 0:
c += 1
if (p-c) == 1: break

print "Answer to PE26 = ",p

I want to execute the same program on C++. But, the program does not complete(keeps on looping on the while loop below). I donít know python that well. Can it be explained to me if the following code snippet is right in c++?

int p = 0;
int n = 997;
int c=0;
for ( p=n;p>1;p-2)

while (((int)pow(10.0,c) Ė 1) % p != 0)
c += 1;

if (p-c==1)