2018-09-30 23:01:58 +01:00
---
id: 5900f4051000cf542c50ff18
title: 'Problem 153: Investigating Gaussian Integers'
2020-11-27 19:02:05 +01:00
challengeType: 5
2019-08-05 09:17:33 -07:00
forumTopicId: 301784
2021-01-13 03:31:00 +01:00
dashedName: problem-153-investigating-gaussian-integers
2018-09-30 23:01:58 +01:00
---
2020-11-27 19:02:05 +01:00
# --description--
2021-07-14 13:05:12 +02:00
As we all know the equation $x^2 = -1$ has no solutions for real $x$.
2018-09-30 23:01:58 +01:00
2021-07-14 13:05:12 +02:00
If we however introduce the imaginary number $i$ this equation has two solutions: $x = i$ and $x = -i$.
2018-09-30 23:01:58 +01:00
2021-07-14 13:05:12 +02:00
If we go a step further the equation ${(x - 3)}^2 = -4$ has two complex solutions: $x = 3 + 2i$ and $x = 3 - 2i$, which are called each others' complex conjugate.
2018-09-30 23:01:58 +01:00
2021-07-14 13:05:12 +02:00
Numbers of the form $a + bi$ are called complex numbers.
2018-09-30 23:01:58 +01:00
2021-07-14 13:05:12 +02:00
In general $a + bi$ and $a − bi$ are each other's complex conjugate. A Gaussian Integer is a complex number $a + bi$ such that both $a$ and $b$ are integers.
2018-09-30 23:01:58 +01:00
2021-07-14 13:05:12 +02:00
The regular integers are also Gaussian integers (with $b = 0$).
2018-09-30 23:01:58 +01:00
2021-07-14 13:05:12 +02:00
To distinguish them from Gaussian integers with $b ≠ 0$ we call such integers "rational integers."
2018-09-30 23:01:58 +01:00
2021-07-14 13:05:12 +02:00
A Gaussian integer is called a divisor of a rational integer $n$ if the result is also a Gaussian integer.
2018-09-30 23:01:58 +01:00
2021-07-14 13:05:12 +02:00
If for example we divide 5 by $1 + 2i$ we can simplify in the following manner:
2018-09-30 23:01:58 +01:00
2021-07-14 13:05:12 +02:00
Multiply numerator and denominator by the complex conjugate of $1 + 2i$: $1 − 2i$.
2018-09-30 23:01:58 +01:00
2021-07-14 13:05:12 +02:00
The result is:
2018-09-30 23:01:58 +01:00
2021-07-14 13:05:12 +02:00
$$\frac{5}{1 + 2i} = \frac{5}{1 + 2i} \frac{1 - 2i}{1 - 2i} = \frac{5(1 - 2i)}{1 - {(2i)}^2} = \frac{5(1 - 2i)}{1 - (-4)} = \frac{5(1 - 2i)}{5} = 1 - 2i$$
2018-09-30 23:01:58 +01:00
2021-07-14 13:05:12 +02:00
So $1 + 2i$ is a divisor of 5.
2018-09-30 23:01:58 +01:00
2021-07-14 13:05:12 +02:00
Note that $1 + i$ is not a divisor of 5 because:
$$\frac{5}{1 + i} = \frac{5}{2} - \frac{5}{2}i$$
Note also that if the Gaussian Integer ($a + bi$) is a divisor of a rational integer $n$, then its complex conjugate ($a − bi$) is also a divisor of $n$. In fact, 5 has six divisors such that the real part is positive: {1, 1 + 2i, 1 − 2i, 2 + i, 2 − i, 5}.
2018-09-30 23:01:58 +01:00
The following is a table of all of the divisors for the first five positive rational integers:
2021-07-14 13:05:12 +02:00
| n | Gaussian integer divisors with positive real part | Sum s(n) of these divisors |
|---|---------------------------------------------------|----------------------------|
| 1 | 1 | 1 |
| 2 | 1, 1 + i, 1 - i, 2 | 5 |
| 3 | 1, 3 | 4 |
| 4 | 1, 1 + i, 1 - i, 2, 2 + 2i, 2 - 2i, 4 | 13 |
| 5 | 1, 1 + 2i, 1 - 2i, 2 + i, 2 - i, 5 | 12 |
For divisors with positive real parts, then, we have: $\displaystyle\sum_{n=1}^5 s(n) = 35$.
For $1 ≤ n ≤ {10}^5$, $\displaystyle\sum_{n = 1}^{{10}^5} s(n) = 17924657155$.
2018-09-30 23:01:58 +01:00
2021-07-14 13:05:12 +02:00
What is $\displaystyle\sum_{n=1}^{{10}^8} s(n)$?
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
# --hints--
2018-09-30 23:01:58 +01:00
2021-07-14 13:05:12 +02:00
`sumGaussianIntegers()` should return `17971254122360636` .
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
```js
2021-07-14 13:05:12 +02:00
assert.strictEqual(sumGaussianIntegers(), 17971254122360636);
2018-09-30 23:01:58 +01:00
```
2020-11-27 19:02:05 +01:00
# --seed--
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
## --seed-contents--
2018-09-30 23:01:58 +01:00
```js
2021-07-14 13:05:12 +02:00
function sumGaussianIntegers() {
2020-09-15 09:57:40 -07:00
2018-09-30 23:01:58 +01:00
return true;
}
2021-07-14 13:05:12 +02:00
sumGaussianIntegers();
2018-09-30 23:01:58 +01:00
```
2020-11-27 19:02:05 +01:00
# --solutions--
2018-09-30 23:01:58 +01:00
```js
// solution required
```