RUNTIME ERROR(SIGPE) in FLOW016 problem

I am recieving a RUNTIME ERROR(SIGPE) in FLOW016 problem .Can anybody help me with a solution…

My solution is : https://www.codechef.com/viewsolution/30711612

Your GCD is wrong. You check if A==0 but then divides by B that can be 0

if(A==0)
    return B;
return gcd(B,A%B);
1 Like

Thanks bro for helping