Solve Simultaneous Pairs of Linear Congruence Equations

Write a C/C++ program to solve given simultaneous pairs of Linear Congruence Equations.

 

For example,


Input:

x=1(mod 2)
x=2(mod 3)

Output: Solution of the given equations is x=5(mod 6)
 

Input:

x=2(mod 4)
x=4(mod 6)
x=2(mod 8)

Output: Solution of the given equations is x=10(mod 192)
 

Input:

x=0(mod 2)
x=1(mod 3)

Output: Solution of the given equations is x=4(mod 6)
 

Input:

x=4(mod 4)
x=2(mod 6)

Output: The given equation has no solution.
 

Input:

x=3(mod 4)
x=2(mod 8)

Output: The given equation has no solution.

 
Related post: Find general solution to given Linear Congruence Equation
 

C++

Download   Run Code


Input:

x=2(mod 4)
x=4(mod 6)
x=2(mod 8)

Output:

Solution of the given equations is x=10(mod 192)

 
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)

Loading...

Thanks for reading.

Please use our online compiler to post code in comments. To contribute, get in touch with us.
Like us? Please spread the word and help us grow. Happy coding 🙂
 


Leave a Reply

avatar
  Subscribe  
Notify of