I'm trying to write, in CodeBlocks, a recursive function that check if a natural number (a long double) is a perfect square. This function called "Square" takes in input, by reference, the long double S and n (setted in the beginning at 1), a bool T and the long double to compare.
Here the code:
void Square(long double& S, long double& n, bool& T,long double k){
        S=S+2*n+1;
        n++;
        if(S==k){
             T=true;
        }
        if(S>k){
            T=false;
        }
        if(S<k){
            Square(S,n,T,k);
        }
}
And in the main function:
long double S,n,k;
bool T=false;
for(long double b=1;b<50000;b++){
    for(long double a=1;a<b;a++){
        S=1;
        n=1;
        T=false;
        k=12*a*b*b*b-3*a*a*a*a;
        Square(S,n,T,k);
        if(T==true){
            cout<<a<<"    "<<b<<"   "<<k<<endl;
        }
    }
}
Sometimes occours this error: "Process returned -1073741571 (0xC00000FD)" (for example when (a = 108 and b = 121) and the program stops. Any help?
 
     
     
    