X is positive integer of the form pqpqpqrq, such that (X-1) is a perfect square; where p, q and r different digits from 0 to 9, with p being nonzero. Determine X

Brute-force solution : Code: #include <stdio.h> #include <math.h> int main() { unsigned int p,q,r, Num, SNum; for(int p = 1; p < 10; ++p) { for(int q = 0; q < 10; ++q) { for(int r = 0; r < 10; ++r) { // pqpqpqrq Num = p*(10101000); Num += q*(1010101); Num += r*10; Num -= 1; SNum = floor(sqrt(Num)); if(SNum * SNum == Num) {printf("p=%d q=%d r=%d\nX=%d\nX-1=%d\nsqrt(X-1)=%d\n\n", p,q,r,Num+1,Num,SNum);} } } } return 0; } Output :: Code: p=4 q=5 r=6 X=45454565 X-1=45454564 sqrt(X-1)=6742 p=8 q=2 r=0 X=82828202 X-1=82828201 sqrt(X-1)=9101 Process returned 0 (0x0) execution time : 0.031 s