Math, asked by albinmathew9444, 11 months ago

Finding remainder of large numbers divided by small number

Answers

Answered by vikrantsoni
0

Answer:

Can you please eloborate you question.

Answered by ratneshmaurya2001
0

Answer:

I hope you are asking on basis for coding purpose.

Approach

We must divide the number in order to discover the remaining. However, because splitting large numbers is a difficult task, we shall divide digit by digit. And then put the rest of it away. This procedure should be repeated for the entire string of numbers, from MSB to LSB. Finally, the remaining text is printed.

Program to illustrate the working of our solution

#include <iostream>

#include <string.h>

using namespace std;

int calcRem(string num, int R){

  int currDigit, rem = 0;

  for (int i = 0; i < num.length(); i++) {

     currDigit = rem * 10 + (num[i] - '0');

     rem = currDigit % R;

  }

  return rem;

}

Similar questions