Answer the question
In order to leave comments, you need to log in
Prompt algorithm
It is necessary to find the maximum possible number that cannot be obtained by combining two given numbers using summation operations. For example, the numbers 2 and 5 are given - the answer is 3, the remaining natural numbers can be obtained by combining 2 and 5 (21 = 5 + 5 + 5 + 2 + 2 +2). If the answer is infinity, this should also be reported.
The numbers are all natural.
Answer the question
In order to leave comments, you need to log in
Here is the complete solution.
Let the initial numbers be a and b.
1. Obviously, if the numbers are not coprime, the answer is infinity.
2. It is known that any number m can be represented as m = ka+lb with coprime a and b.
For m not to be decomposable, one of two conditions must be satisfied: k<0 or l<0.
Note that (k+b)a+(la)b = ka+lb = (kb)a+(l+a)b. This implies that for an indecomposable m, there must exist k and l such that k<0, l<a or k<b, l<0 (otherwise, one can find an expansion using one of these formulas).
Since we know the upper limits for both k and l, and these limits are independent,
we can take these variables to the maximum.
m = (-1)a+(a-1)b = (b-1)a+(-1)b = ab-ab.
Therefore, for coprime a and b, the answer is ab-ab, and for those having common divisors, infinity.
As usual, 2 ways - Blind enumeration and functional analysis.
I think you need to write a system of simple equations
Infinity will be when they are not coprime, in all other cases the answer is finite. Then google Diophantine equations, I won’t deduce the exact solution before I fall asleep =)
I can’t answer myself (I’m an applied programmer, not a mathematician).
To be honest: do you need it for some practical tasks?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question