the question

Find all the numbers $\overline{abcd}$ (4-digit number in base 10) that check the relationship. $$5a^2+5b^2+2c^2+2d^2-2ac-2cd-4ab-4bd-16a+16b-4d+20=0$$

my idea

I tried grouping them in a whole perfect square or I tried using formulas such as



I tried many of this variants but none of them got me to a useful form.

I don't know where to start! THope one of you can help me! Thank you!

  • $\begingroup$ what is d? please elaborate as you gave the number as $\overline{abc}$, so should the number be $\overline{abcd}$? $\endgroup$ Commented Feb 7 at 17:24
  • $\begingroup$ @peterwhy see the edited. sorry for my misspelling. $\endgroup$ Commented Feb 7 at 17:35
  • $\begingroup$ @SarbanBhattacharya see the edited. sorry for my misspelling $\endgroup$ Commented Feb 7 at 17:36
  • 3
    $\begingroup$ I do not see any useful sort of pattern and would resort to coding a brute force search. In doing so, you can find the only solution is $2022$. $\endgroup$
    – JMoravitz
    Commented Feb 7 at 17:37
  • 1
    $\begingroup$ @Dan Yes, it is! $\endgroup$ Commented Feb 8 at 7:33

2 Answers 2


The given expression can be written $$ (a-c)^2 +(c-d)^2 + (2a-b-4)^2 + (2b-d+2)^2$$ Knowing this is zero, immediately gives us $$\overline{abcd}=2022$$ I confess that it took me a while to find this - annoyingly WA was no help.

  • $\begingroup$ You should preferably use $\overline{abcd} \ $ in place of $abcd$. $\endgroup$
    – Sahaj
    Commented Feb 7 at 19:01
  • $\begingroup$ @Sahaj - I have done so. Although I am not familiar with that notation. $\endgroup$
    – Blitzer
    Commented Feb 7 at 19:04
  • 1
    $\begingroup$ nice idea...I wrote software for what Kap called a "homothety" meaning take symmetric integer matrices $A,B,$ find out if there are any matrices $P$ of integers with $P^T A P = B$ where I also supply a bound on the absolute values of the entries of $P.$ Taking just the quadratic form part only, it returns exactly your expression (without the constants $-4,2$ ). If I'd thought to check that.... $\endgroup$
    – Will Jagy
    Commented Feb 7 at 20:36

Complete square with respect to $a$, then $b$, then $c$, then $d$. The left side turns out to be $$ 5 \left(a -\frac{2 b}{5}-\frac{c}{5}-\frac{8}{5}\right)^{2} + \frac{21}{5} \left(b -\frac{2 c}{21}+\frac{8}{7}-\frac{10 d}{21}\right)^{2} + \frac{37}{21} \left(c -\frac{24}{37}-\frac{25 d}{37}\right)^{2}+ \frac{9}{37} \left(d -2\right)^{2}$$ and the unique solution to the equations $$ \eqalign{a -\frac{2 b}{5}-\frac{c}{5}-\frac{8}{5} &= 0\cr b -\frac{2 c}{21}+\frac{8}{7}-\frac{10 d}{21} &= 0\cr c -\frac{24}{37}-\frac{25 d}{37} &= 0\cr d - 2 &= 0\cr}$$ is $a = 2$, $b = 0$, $c = 2$, $d = 2$.

  • $\begingroup$ Completing the square always comes in so handy. +1. $\endgroup$
    – Sahaj
    Commented Feb 7 at 18:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .