Bigint division doubt

how to write code for division of one bigint by another bigint or to find the %

@rohit_1906 hi,to find quotient, we can print quotient as we progress in our algorithm or store those numbers in array and print them later ,||ly for mod also:
Initialize mod = 0
First take first digit (from right) and find
mod using formula:
mod = (mod * 10 + digit) % m
quo[i] = mod / m
where i denotes the position of quotient number

Let’s take an example.
num = 12345
m = 9
Initialize mod = 0
quo[i] = (mod * 10 + num[i]) / m
mod = (mod * 10 + num[i]) % m
Where i denotes the position of the i-th digit

  1. quo[1] = (0 * 10 + 1) / 9 = 0
    mod = (0 * 10 + 1) % 9 = 1
  2. quo[2] = (1 * 10 + 2) / 9 = 12 / 9 = 1
    mod = (1 * 10 + 2) % 9 = 12 % 9 = 3
  3. quo[3] = (3 * 10 + 3) / 9 = 33 / 9 = 3
    mod = (3 * 10 + 3) % 9 = 33 % 9 = 6
  4. quo[4] = (6 * 10 + 4) / 9 = 64 / 9 = 7
    mod = (6 * 10 + 4) % 9 = 64 % 9 = 1
  5. quo[5] = (1 * 10 + 5) / 9 = 15 / 9 = 1
    mod = (1 * 10 + 5) % 9 = 15 % 9 = 6

Concatenating all values of quotient together
(from 1 to n) where n is the number of digits.
Thus, modulus is 6 and quotient is 01371.
We can use this technique to find quotient and remainder of big numbers also.

yes yes thank you … understood this … but my next doubt is here you have taken m as single digit … how to solve bigint/bigint like for solving divsion in ncr or in equations where both the dividend and the divisor are big int

and please also let me know how to find square or cube of bigints

@rohit_1906 hey,for that case both are big int you have to apply school division which you normally do,here is code:

can you please check or resend the code link cause im opening the link …showing no code

@rohit_1906 https://sapphireengine.com/@/k23fw7

@rohit_1906 For square of two big nos also you have to do school multiplication,here is code for reference:

this link has the same issue …no code

here… any idea how to find ncr if both n and r are bigint

@rohit_1906 here is code for division:


for square:https://ideone.com/mV4ylo

@rohit_1906 for ncr apko formula khol kr siomplify krna pdega ,and then apko multiplication of large no and division hi lgana pdega ,in sab cases me aisa hi hai ,simply krna hota hai school methods.