0

I am trying to compute % of large numbers. I managed so far with the dividend to be large and the mod represented as integer. I have no idea how to do otherwise. I need this exactly for Large numbers division that is why I need this. No, I will not use BigInts library, as it is not accepted by online judges. Moreover, I'd like to know how to do it myself.

This is what I have written for just one large number.

int mod(string num, int a) 
{ 
int res = 0; 

for (int i = 0; i < num.length(); i++) 
     res = (res*10 + (int)num[i] - '0') %a; 

return res; 
} 
HariUserX
  • 1,341
  • 1
  • 9
  • 17
Prekzursil
  • 11
  • 2

0 Answers0