1

I have always faced lots of questions on online coding platforms dealing with nCr mod M where M is usually a prime. In the cases where it is not, we usually prefer to use the Chinese remainder theorem

Could we do this more easily than the Chinese Remainder Theorem, i.e. by writing less code if we simply have to calculate N mod M where M is not prime?

Sumurai8
  • 20,333
  • 11
  • 66
  • 100
Kavish Dwivedi
  • 735
  • 6
  • 24
  • What language are you using? Can you use modulus operator? – Jacob Seleznev Apr 08 '13 at 06:52
  • @JacobSeleznev:I am using C/C++ – Kavish Dwivedi Apr 08 '13 at 06:56
  • Do you want to determine a number n that when divided by some given divisors leaves given remainders? Or you want to find the remainder of division of one number by another([Modulo](http://en.wikipedia.org/wiki/Modulo_operation) operation) – Jacob Seleznev Apr 08 '13 at 07:13
  • 3
    @KavishDwivedi you have to give more info about the field (in a algebraic sense) you are working on. For instance, why `int v = n % m` is not enough. – UmNyobe Apr 08 '13 at 08:20
  • 1
    @KavishDwivedi, your problem, which I understand is talking about [this](http://comeoncodeon.wordpress.com/2011/07/31/combination/), is probably more appropriate for [math.stackexchange.com](http://math.stackexchange.com). – Simon MᶜKenzie Apr 09 '13 at 09:26

0 Answers0