4
$\begingroup$

How many six-digit numbers are there where the third digit is equal to the second last digit, the digit in the ten-thousands place is equal to the digit in the hundreds place, and the product of all the digits is equal to the square of a natural number?

Attempt:

We are looking for numbers of the form $abc bcf$, where $ab^2c^2f=n^2$ for some $n \in \mathbb{N}$. This means that $af = m^2$ for some $m \in \mathbb{N}$. Now, I have separated it into three cases:

  1. Case: $a = f$, there are $10^3$ such numbers,
  2. Case: $a = x^2$ and $f = y^2$ and $a \neq f$, there are $10^2 \cdot 6$ such numbers,
  3. Case: $a = 2$ and $f = 8$ or $f = 2$ and $a = 8$, there are $2 \cdot 10^2$ such numbers.

Thus, I found that there are 1800 such numbers (but the solutions state 1458). Where did I go wrong?

Thank you in advance for your help.

Note: $0$ is not a natural number here.

$\endgroup$
10
  • 2
    $\begingroup$ Zero is a square, is it not? So maybe some $10$s rather than $9$s? $\endgroup$
    – fleablood
    Commented Jun 19 at 17:38
  • $\begingroup$ Do you know whether or not the problem considers $0$ to be a natural number? This makes a significant difference re: the problem statement that "... the product of all the digits is equal to the square of a natural number". $\endgroup$ Commented Jun 19 at 17:43
  • 1
    $\begingroup$ $0$ is not a natural number here ... $\endgroup$
    – user1316790
    Commented Jun 19 at 17:44
  • 1
    $\begingroup$ If you knew $0$ is not a natural number, why did you edit it to replace the $9$s with $10$s? If zero is not a natural number my comment wasn't valid and you shouldn't have changed anything. $\endgroup$
    – fleablood
    Commented Jun 19 at 21:38
  • 1
    $\begingroup$ I think the deleted answer gives a hint to how the may have double counted. In the $a,f$ are not square but have a square product the only way to do that is with odd powers of $2$. $(2,2),(2,8)$ and $(8,8)$. But $(2,2)$ and $(8,8)$ were included in case $1$ so double counting. And maybe a failure to count $(2,8)$ separately from $(8,2)$. So they get $18\times 81$ rather than your (and I believe it to be correct) $17\times 81$. (I wouldn't mind if someone could confirm that.) $\endgroup$
    – fleablood
    Commented Jun 19 at 22:14

2 Answers 2

2
$\begingroup$

If, as indicated in the edit, $0$ is not a natural number, that means the product of digits can't be zero and there are only $9$ possibilities for each digit. Consequently every $10$ in your calculation should be a $9$. This leads to an answer of $1377$.

A quick python script confirms that there are exactly $1377$ integers with this property, so the answer you were given is wrong. (The largest possible product of digits is $9^6=729^2$.)

squares=[n*n for n in range(1,730)]
r=0
for n in range(100000,1000000):
    x=str(n)
    y=1
    for z in x:
        y*=int(z)
    if y in squares and x[1]==x[3] and x[2]==x[4]:
        r+=1
print(r)

Incidentally, if $0$ is treated as a natural number, the answer is not $2600$, despite two previous posts. This is because numbers where $af$ is not a square but $b$ or $c$ is $0$ still give a square product. There are $19$ choices for $b,c$ with at least one $0$. There are $90$ overall possibilities for $a,f$ and of these $26$ have $af$ being a square (nine with $a=f$, nine with $f=0$, six combinations of $1,4,9$ and two of $2,8$) so there are $19\times 64=1216$ cases missing from the other answers, giving a total of $3816$.

$\endgroup$
-1
$\begingroup$

EDIT: Especially Lime correctly pointed out in their answer that my math didn't properly account for all the $abcbcf=0$ cases, so here is a fixed version.

We are looking for numbers of the form $abcbcf$, where $ab^2c^2f=n^2$ for some $n∈N$.
This means that $af=m^2$ for some $m∈N$.

This looks good so far, but the issue of whether $a=0$ creates a valid "six digit number" seems like an important detail. (As well as the question of whether $n\in N$ includes $n=0$ or not.)

If we start by counting only the non-zero-$n$ solutions to $ab^2c^2f=n^2$ then $af=m^2$ applies and that is solved most simply when:

Case 1: $a=f \rightarrow af=a^2=m^2$, there are 9 non-zero choices for $a$, giving $9\cdot9^2$ such numbers.

That leaves the $a\neq f$ cases, for which we can see that $af=m^2\rightarrow af=p^2q^2$ for which $a$ can only be factored out in one of two ways:

Case 2a: $a=p^2 \rightarrow af=p^2(f)=p^2q^2 \rightarrow f=q^2$, there are three choices for $a$ leaving two remaining choices for $b\neq a$, giving $3\cdot 2\cdot9^2$ such numbers.

Case 2b: $a\neq p^2 \rightarrow m^2=p^2q^2=p(pq^2)$, which gives two choices for $a$ leaving one choice for $b\neq a$, giving $2\cdot 1\cdot9^2$ such numbers.

That all together that gives: $$ 9\cdot9^2+3\cdot 2\cdot9^2+2\cdot 1\cdot9^2=(17)\cdot9^2=1377 $$ solutions to $abcbcf=n^2$ for non-zero $n\in N$.

That (potentially) leaves the $n=0$ cases, which are much easier to account for (since there are no further requirements containing the digits make squares or whatnot). If we assume that $012123$ does not count as a "six-digit number" then $a\neq 0$ applies and:

Case 3a: $b=0$, leaves 9 choices each for $a$, $c$, and $f$, giving $9^3$ such numbers.

Case 3b: $c=0$, leaves 9 choices each for $a$, $b$, and $f$, giving $9^3$ such numbers.

Case 3c: $f=0$, leaves 9 choices each for $a$, $b$, and $c$, giving $9^3$ such numbers.

Case 3d: $b=c=0$, leaves 9 choices each for $a$ and $f$, giving $9^2$ such numbers.

Case 3e: $b=f=0$, leaves 9 choices each for $a$ and $c$, giving $9^2$ such numbers.

Case 3f: $c=f=0$, leaves 9 choices each for $a$ and $b$, giving $9^2$ such numbers.

Case 3g: $b=c=f=0$, leaves 9 choices for $a$, giving $9^1$ such numbers.

That all together that gives: $$ (3)\cdot9^3+(3)\cdot9^2+(1)\cdot9^1=2439 $$ solutions to $abcbcf=0$ when $a\neq 0$.

This makes the grand total: $$ 1377+2439=3816 $$ as pointed out by Especially Lime


Also, it should be noted somewhere that this all assumes the decimal base.

So $a\in\{1,2,3,4,5,6,7,8,9\}$ and similarly for $b$, $c$, and $f$ in Case 1.

For Case 2a, only $a\in\{1,4,9\}$ will satisfy the conditions of $ a=p^2\leq9$ (for $a\neq0$).

For Case 2b, only $p=2=q$ can satisfy $p\cdot q^2\leq 9$. This leaves only $a\in\{2,8\}$.

$\endgroup$

You must log in to answer this question.