1
$\begingroup$

I have an equation of the form:

$$10^{n+1}=\sum_{i=1}^{n}{(a_{i}10^{i}-b_{i}9^{i})}$$

where $0 < a_{i} \leq 20$ and $0 < b_{i} \leq 18$.

By inspection, I can see that for $n=1$, $a=19$ and $b=10$ is a solution and I can verify in a spreadsheet that it is the only solution.

Is there an easy way to find the number of solutions (and what they are) for a given $n$, for example when $n=5$, or is this something that would have to be done by brute force with a computer (meaning checking all $(a,b)$ pairs to see if they are a solution)?

$\endgroup$
  • 2
    $\begingroup$ This is linear diophantine equation in $2n$ variables. For the existence of solution, we must have $gcd(a_1,b_1,a_2,b_2...a_n,b_n)$ divides $10^{n+1}$. Rest, I hope you know how to find all the solutions of Linear Diophantine equation using Euclids algorithm. $\endgroup$ – ersh Apr 2 at 5:26
  • $\begingroup$ @ersh I was hoping for some theorem from number theory that says 'every power of 10 can be expressed as the difference between powers of 10 and powers of 9', or something like that, and hoping for a uniqueness theorem. The bounds of a & b vary in what I'm using this equation for so I'm trying to avoid Euclids alg to reduce processor load. $\endgroup$ – Rasputin Apr 2 at 5:55
  • $\begingroup$ @farruhota there is a $+1$ in the 10 exponent, so for $n=1$ it is $100=10a-9b$. Is there only one solution for a given $n$ and does it matter on the bounds for $a$ and $b$? $\endgroup$ – Rasputin Apr 2 at 14:25
3
$\begingroup$

Presumably your $a_i$ and $b_i$ are integers. Write your equation as

$$ \sum_{i=1}^n b_i 9^i = - 10^{n+1} + \sum_{i=1}^n a_i 10^i $$

Now $\sum_{i=1}^n b_i 9^i$ is a multiple of $9$, and can be any such multiple between $\sum_{i=1}^n 9^i = (9^{n+1}-9)/8$ and $\sum_{i=1}^n 18 \cdot 9^i = (9^{n+2}-9^2)/4$. Similarly, $-10^{n+1} + \sum_{i=1}^n a_i 10^i$ can be any multiple of $10$ between $(-8 \cdot 10^{n+1}-10)/9$ and $(11\cdot 10^{n+1}-200)/9$.

For $n=1$, the only multiple of $90$ between $9$ and $100$ is $90$, yielding your solution.

For $n=5$, there are $12547$ multiples of $90$ between $66429$ and $1195722$. For each such multiple $v$, you want to compute the number of $a$ such that $v = - 10^{6} + \sum_{i=1}^5 a_i \cdot 10^i $ and the number of $b$ such that $v = \sum_{i=1}^5 b_i \cdot 9^i$, multiply them, and add the results.

$\endgroup$
  • $\begingroup$ I see that it works but how do you get from the sum of $9^{i}$ to $(9^{n+1} - 9)/8$ (similar question for the same relationship when evaluating the other sums)? Is that an identity like SUM($a x^{i}$) = $(x^{n+?}-x^{?}) / (x-1)$? $\endgroup$ – Rasputin Apr 2 at 18:03
  • $\begingroup$ Yes, sum of a finite geometric series. $\endgroup$ – Robert Israel Apr 2 at 20:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.