Home > Article > Backend Development > C/C++ module equation solution program
In mathematics, modular equation is an algebraic equation that satisfies modulo in the sense of a modular problem. That is, given multiple functions on a moduli space, the modular equation is the equation between them, or in other words, the modular identity.
The most common usage of the term "modular" equations is related to the modular problem of elliptic curves. In this case, the moduli space itself is one-dimensional. This means that any two rational functions F and G in the domain of modular curve functions will satisfy the modular equation P(F, G) = 0 where P is a non-zero polynomial of two variables over complex numbers. For appropriate non-degenerate choices of F and G, the equation P(X,Y) = 0 will actually define the modular curve.
You just saw a strange mathematical expression of the form
B ≡ (A mod X)
This means that B is congruent to A mod X. Let's take an example,
21 ≡ 5( mod 4)
The symbol equal means "equivalent". In the above equation, 21 and 5 are equivalent. This is because 21 modulo 4 = 1 is equal to 5 modulo 4 = 1. Another example is 51 eq 16(mod 7)
In this problem we have two integers a and b and we have to find the number of possible values of x that follow the modular equation (A mod X)=B , where the X solution of the modular equation.
For example
Input: A = 26, B = 2 Output: X can take 6 values
X can be equal to any one of {3, 4, 6, 8, 12, 24}, because these The A modulus of any one of the values is equal to 2 i. For example, (26 mod 3) = (26 mod 4) = (26 mod 6) = (26 mod 8) = .... = 2
We have the equation A mod X = B
Condition
if (A = B) Then there will be countless values, where A is always greater than X.
if (A
Now only the last situation remains (A > B).
Now, in this case, we will use the relation
Dividend = Divisor * Quotient Remainder
X, i.e. given A (i.e. dividend) and B (i.e. remainder).
Now
A = X * Quotient B
Suppose the quotient is expressed as Y
∴ A = = )
∴ X is the divisor of (A - B)Find the divisor of (A - B) The number is the main problem, and the number of divisors is the possible values that X can take.
We know that the solution value of A mod X will be from (0 to X – 1) taking all such X such that X > B.
In this way we can conclude that the number of divisors of (A – B) is greater than B, and all possible values X can satisfy A mod X = B
Example #include <iostream>
#include <math.h>
using namespace std;
int Divisors(int A, int B) {
int N = (A - B);
int D = 0;
for (int i = 1; i <= sqrt(N); i++) {
if ((N % i) == 0) {
if (i > B)
D++;
if ((N / i) != i && (N / i) > B)
D++;
}
}
return D;
}
int PossibleWaysUtil(int A, int B) {
if (A == B)
return -1;
if (A < B)
return 0;
int D = 0;
D = Divisors(A, B);
return D;
}
int main() {
int A = 26, B = 2;
int Sol = PossibleWaysUtil(A, B);
if (Sol == -1) {
cout <<" X can take Infinitely many values greater than " << A << "\n";
} else {
cout << " X can take " << Sol << " values\n";
return 0;
}
}
The above is the detailed content of C/C++ module equation solution program. For more information, please follow other related articles on the PHP Chinese website!