Hi The following is my code I am getting Arithmetic exception in gcd function at rem=a%b can anyone help me finf why? how do I fix it?
Code:#include "Pionare.h" int main(int argc, char * argv[]) { int n=atoi(argv[1]);// convert string to integer Pionare Pionare1(n); return 0; } Pionare::Pionare(int n) { cout << "am in cons"; this->n=n; cout << "n is" << n; Findab(); } void Pionare::Findab(){ cout << "n is" << n; for(b=1;b<=n;b++){ for(a=1;a<= b*1.414;a++){ cout << "am here"; if(Gcd(a,b)==1){ p=a*a*a*a-6*a*a*b*b+b*b*b*b; q=(a*a+b*b)*(a*a+b*b); B=-54*(p*p*p*p*p*p-33*p*p*p*p*q*q-33*p*p*q*q*q*q+q*q*q*q*q*q); A=-27*(p*p*p*p+14*p*p*q*q+q*q*q*q); //output to file } } } } int Pionare::Gcd(int a,int b){ int rem; cout<<a<<endl<<b<<endl; while (a !=0) { rem = a % b; a= b; b = rem; } return (a); }