Code: Select all
i=r*s/gcd(r,s);
r*s suffers from overflow as its value can exceed MAX_INT_LIMIT..
2 solutions..
1] convert to r / gcd(r,s) * s or
2] use long long
Moderator: Board moderators
Code: Select all
i=r*s/gcd(r,s);
}the way may recursive
or->
a loop i:from 2 to sqrt(N)
if(N%i == 0)
then add both i and N/i to the divisor list.