Vishal1003 / Algorithms

🎓 Important Algorithms and their implementations
MIT License
33 stars 99 forks source link

Add files via upload #110

Closed Shreyas12345678 closed 4 years ago

Shreyas12345678 commented 4 years ago

Chinese Remainder Theorem:

We are given two arrays num[0..k-1] and rem[0..k-1]. In num[0..k-1], every pair is coprime (gcd for every pair is 1). We need to find minimum positive number x such that:

 x % num[0]    =  rem[0], 
 x % num[1]    =  rem[1], 
 .......................
 x % num[k-1]  =  rem[k-1] 

Basically, we are given k numbers which are pairwise coprime, and given remainders of these numbers when an unknown number x is divided by them. We need to find the minimum possible value of x that produces given remainders.

Shreyas12345678 commented 4 years ago

Number Theory Chinese Remainder Theorem