All are 5-digit numbers with the same 5 digits

Given that A A is a 5-digit number and that 8 A 5 \dfrac{8A}{5} , 9 A 5 \dfrac{9A}{5} , 21 A 5 \dfrac{21A}{5} and 39 A 5 \dfrac{39A}{5} are all 5-digit numbers with the same 5 digits as A A . Find A A .


The answer is 12195.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

6 solutions

Chris Lewis
May 13, 2019

My approach was brute-force, after narrowing down the options as much as I could.

Obviously 10000 A 99999 10000 \le A \le 99999 in order to have 5 5 digits. [90000 possibilities]

Now, we must have A 12820 A \le 12820 , otherwise 39 A 5 \frac{39A}{5} would have too many digits. [2821 possibilities]

Next, A A must be a multiple of 5 5 , otherwise 8 A 5 \frac{8A}{5} would not be a whole number. [565 possibilities]

So A = 5 x A=5x for some integer x x . The numbers in the list are 5 x , 8 x , 9 x , 21 x , 39 x 5x,8x,9x,21x,39x . Since these are made up of the same digits, they must all have the same remainder when divided by 9 9 . So 9 9 must divide the difference of any two of the numbers in the list, in particular 8 x 8x and 9 x 9x . So 9 9 divides x x , and 45 45 divides A A [62 possibilities]

There are other restrictions that could be used here, but at this point I reverted to brute force (ie just checking each of the multiples of 45 45 from 10035 10035 up to 12780 12780 ), and found just one solution, 12195 \boxed{12195} . [1 possibility]

I'd be interested, though: what other restrictions could easily be implemented to narrow down further from the 62 possibilities?

Having an answer from narrowing down / elimination process, is it appropriate for me to post it here when the question is labelled as one of computer science variation? It can be done down to just two.

Saya Suka - 2 years ago

Although we don't know this, it is likely that the five numbers follow a cyclic number pattern, so we could test this first and hope that we arrive at the answer (which fortunately it does). Being 5 5 digits, then by the properties of a cyclic number, A = 5 99999 y A = \frac{5 \cdot 99999}{y} for some factor y y of 99999 99999 . Since 99999 = 3 2 4 1 1 27 1 1 99999 = 3^2 \cdot 41^1 \cdot 271^1 , it has ( 2 + 1 ) ( 1 + 1 ) ( 1 + 1 ) = 12 (2 + 1)(1 + 1)(1 + 1) = 12 possible factors to test ( 1 1 , 3 3 , 9 9 , 41 41 , 123 123 , 271 271 , 369 369 , 813 813 , 2439 2439 , 11111 11111 , 33333 33333 , and 99999 99999 ), but only y = 41 y = 41 gives an A A such that 10000 A 12820 10000 \leq A \leq 12820 , and that is A = 12195 A = 12195 . So while not guaranteed to give the correct answer (or only answer), this does cut down the testing to 12 12 tries.

David Vreken - 2 years ago

Log in to reply

Yes, just wanted to try the no assumption of cyclic way of doing this, when I haven't heard of the word long time ago.

Saya Suka - 2 years ago

One of the first things we notice is that A is always a multiple of 5 and is less than 12821 (to fit the constraint of 39A/5 being a five-digit number). Working along these lines, we can use this Java code.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class test {
    public static void main (String[] args) throws java.lang.Exception {
        int a = 10000;
        int eight = -1;
        int nine = -1;
        int twentyone = -1;
        int thirtynine = -1;
        while (a < 12821) {
            eight = 8*a / 5;
            nine = 9*a / 5;
            twentyone = 21*a / 5;
            thirtynine = 39*a / 5;
            if (checkDigits(a, eight)&&checkDigits(a, nine)&&checkDigits(a, twentyone)&&checkDigits(a, thirtynine)){
                break;
            } else {
                a += 5;
            }
        }
        System.out.println(a);

    }
    public static boolean checkDigits(int x, int y){
        String xStr = Integer.toString(x);
        char[] xD = xStr.toCharArray();
        ArrayList<Character> xDigits = new ArrayList<Character>();
        for (char c: xD){
            xDigits.add(c);
        }
        String yStr = Integer.toString(y);
        char[] yD = yStr.toCharArray();
        for (int i = 0; i < yD.length; i++){
            if (xDigits.contains(yD[i])){
                xDigits.remove(xDigits.indexOf(yD[i]));
            }
        }
        if (xDigits.size() == 0){
            return true;
        } else {
            return false;
        }
    }
}

This is a rather long approach and no doubt there are more efficient algorithms for doing so. In any case, running the code gives us 12195.

Computer screening of all integers from 10000 to 99999

Table [ If [ d = Sort [ IntegerDigits [ a ] ] ; ( 8 a 5 Z 9 a 5 Z 21 a 5 Z 39 a 5 Z ) ( 10000 8 a 5 99999 10000 9 a 5 99999 10000 21 a 5 99999 10000 39 a 5 99999 ) ( d = Sort [ IntegerDigits [ 8 a 5 ] ] d = Sort [ IntegerDigits [ 9 a 5 ] ] d = Sort [ IntegerDigits [ 21 a 5 ] ] d = Sort [ IntegerDigits [ 39 a 5 ] ] ) , a , Nothing ] , { a , 10000 , 99999 } ] 12195 \text{Table}\left[\text{If}\left[d=\text{Sort}[\text{IntegerDigits}[a]]; \\ \left(\frac{8 a}{5}\in \mathbb{Z}\land \frac{9 a}{5}\in \mathbb{Z}\land \frac{21 a}{5}\in \mathbb{Z}\land \frac{39 a}{5}\in \mathbb{Z}\right)\land \\ \left(10000\leq \frac{8 a}{5}\leq 99999\land 10000\leq \frac{9 a}{5}\leq 99999\land 10000\leq \frac{21 a}{5}\leq 99999\land 10000\leq \frac{39 a}{5}\leq 99999\right)\land \\ \left(d=\text{Sort}\left[\text{IntegerDigits}\left[\frac{8 a}{5}\right]\right]\land d=\text{Sort}\left[\text{IntegerDigits}\left[\frac{9 a}{5}\right]\right]\land \\ d=\text{Sort}\left[\text{IntegerDigits}\left[\frac{21 a}{5}\right]\right]\land d=\text{Sort}\left[\text{IntegerDigits}\left[\frac{39 a}{5}\right]\right]\right), \\ a,\text{Nothing}\right],\{a,10000,99999\}\right] \Rightarrow 12195

Yes, I noticed the multiple of 5 and being less than 12820 phenomena. I did not take advantage of them. The screening for the fractions being integers was necessary so that the IntegerDigits function would not create errors.

Wang Xingyu
May 22, 2019

A is multiple of 5. Write A/5 as i , i ranges from 10,000//5 to 100,000//39

1
2
3
4
5
6
7
8
    for i in range(10000//5, 100000//39):
        A5 = list(str(i*5))
        A8 = list(str(i*8))
        A9 = list(str(i*9))
        A21 = list(str(i*21))
        A39 = list(str(i*39))
        if sorted(A5) == sorted(A8) == sorted(A9) == sorted(A21) == sorted(A39): 
            print(i, i*5)

Saya Suka
May 13, 2019

We have five clues, four multiples and the information about the same digits. Since all of them are five digit number, A > 10000 and the largest 39A/5 < 100000, so we have 10000 < A < 12821 AND A is divisible by five. So right away we already know A = 1###0 or A = 1###5, with limited options for the second digit, either 0 or 1 or 2.
One of the clues are 9A/5, so if A have the same digits as that, then A's sum of digits must also be divisible by nine. Also, from A > 10000 and 39A/5 = 7.8A > 78000, then at least one of A's digit MUST include 8 or 9. From 39A/5 < 100000 and clue 21A/5, we get 42000 < 4.2A < 53847, making either 4 or 5 another must have. If A = 1###0, then we'll have a set A = {1, {0, 1, 2}, {{4, 5}, {8, 9}}, {{8, 9}, {4, 5}}, 0}, but no digit combination from this set can get a sum of multiple of nine. This told us that A must be in the form of 1###5.
To complete the number, we have to complement it with three other digits that sums at 12, 11 or 10 (from second digit of 0 or 1 or 2), since we already acknowledged that 8 or 9 must be included. About the four or five, we can relax that condition a bit because we have a five at the end. We can have either 0+8+4, 0+9+3, 1+9+2 or 2+9+1 (basically the same as the third choice). The other options like 1+8+3 and 2+8+2 can be ignored since you cannot have an eight without a four (if 39A/5 < 90000, then 21A/5 < 48462), so it's no use even when we had a five. So now with A = 1###5, and choices of 0+8+4 (2 ways of 10485 or 10845), 0+9+3 (2 ways of 10395 or 10935) and 2+9+1 (2 ways of 11295 or 12195), we can just do the rest. 2+9+1 only have 2 ways because 2 can't be the fourth digit of A, 1##25, as it implies A/5 will end in digit 5, and multiplication by 8 will end it in 0 for 8A/5, which is not included in the set of 2+9+1.
If five errors in six trials seems too much to do, we can look at the last digit of A/5. For 0+8+4, if A ended with 85 (1##85, specifically, A = 10485), then A/5 ended with 7 (simply double the fourth digit and add one). So both 0+8+4 and 0+9+3 would end up with either 7 or 9 for the last digit of A/5, and 2+9+1 with only 9 (why not 5 have already been discussed earlier). Then multiply back to 8, 1 and 9 from 8A/5, 21A/5 and 39A/5 (just take the LD, last digit). Easily seen on a table, but only when LD of A/5 is nine that we can get back the digits within A. 9x8, 9x1 and 9x9 give out LDs of 2, 9 and 1, respectively, nicely confirming the 2+9+1 option. A is now conveniently 1##95, for 1 and 2 to fill in the blanks. You can be wrong twice here, no worries.


Doing it the table way
Let's make assumptions for all 10 digits if it was the last digit (LD) after the division of A/5.

Last Digit (LD) of A/5 0 1 2 3 4 5 6 7 8 9
x5 (from A = 5A/5) 0 5 0 5 0 5 0 5 0 5
x8 (from 8A/5) 0 8 6 4 2 0 8 6 4 2
x9 (from 9A/5, 39A/5) 0 9 8 7 6 5 4 3 2 1
x1 (from 21A/5) 0 1 2 3 4 5 6 7 8 9

Then use back all the restrictions we have going on before :
1) 39A/5 < 100000 ==> 10000 < A < 12821
2) A must start with 1 and end with either 0 or 5 (after multiplication with 5).
3) A must contain at least one even digit (after multiplication with 8).
4) 42000 < 21A/5 < 53847
==> A must contain at least either one of 4 or 5.
5) 78000 < 39A/5 < 100000
==> A must contain at least either one of 8 or 9.
6) Sum of all 5 digits within A must be a multiple of 9 (after multiplication with 9).


Now use the first 5 restrictions to review the table. Scratch those that could not abide by at least 4 of them, and sum the total of the four possible digits for all probable cases. Then, input the complementary digit below in a new row (which will total up to a multiple of 9).

Last Digit (LD) of A/5 0 1 2 3 4 5 6 7 8 9
x5 (from A = 5A/5) 0 5 0 5 0 5 0 5 0 5
x8 (from 8A/5) 0 8 6 4 2 0 8 6 4 2
x9 (from 9A/5, 39A/5) 0 9 8 7 6 5 4 3 2 1
x1 (from 21A/5) 0 1 2 3 4 5 6 7 8 9
Yes / No X X X X X ? (1) X ? (1)
Partial sum X 23 X X X X 18 X 14 17
Complementary digit(s) X 4 X X X X 0 or 9 X 4 1

In the end, we get 4 possible permutations of A, which are listed below :
1) { 1, 4, 5, 8, 9 } for LD = 1, or
2) { 0, 4, 6, 8, { 0, 9 } } for LD = 6, or
3) { 0, 2, 4, 8, 4 } for LD = 8, or
4) { 1, 1, 2, 5, 9 } for LD = 9.

Fortunately, possibilities 2) and 3) are not valid without a 1 as A's ten thousands digit. As for possibility 1), the least permutation of the digits is outside of the probable range from our first restriction of 10000 < A < 12821 < 14589.

Now, all that's left to be solved is to find the one true and final permutation of { 1, 1, 2, 5, 9 }. It must be in the form of 1###5 as we proposed earlier, but that would need 3! = 6 trials and 5 maximum errors for blind, random fill-in. We already know that A/5 have a last digit of 9, so we cannot have it in the form of 1##25 else the LD becomes 5 instead. By now, the possibilities have been shrunk down to 11295 or 12195 (from the earlier LD ≠ 5 and 10000 < A < 12821 restriction).

Good luck, even when you don't need it anymore now (with 3 attempts allowed to us and you only need two of those).

First off, 39A/5 < 100000
==> 10000 < A < 12821

Basically, you need
1) 1 in ten thousands
2) either 0 or 5 in ones / digits place
3) either 8 or 9 somewhere in the middle
4) the digit sum to be a multiple of 9
5) at least an even digit
6) 4 or 5 if neither existing for the previous conditions

There are 4 possible scenarios for A/5 :
1) a non-zero even as last digit number
2) a zero as last digit number
3) a five as last digit number
4) a non-five odd as last digit number

For 1), A would end in 0 and the multiples with 8, 9, 21 & 39 would all end in 3 distinct non-zero even numbers, so A would look like this :
1 [E1] [E2] [E3] 0

One of the Es would need to be 8, so our multiple of 9 had to be more than 1 + 8 + 0 = 9, and that is either 18 or 27 though neither is possible considering that the other two has to be distinct non-0, non-8 even digits.

For 2), A would end in 00 or 50 and the multiples with 8, 9, 21 & 39 would all end in zeros too, so A would look like this :
1 [X1] [X2] [0 or 5] 0

One of the Xs would need to be 8 or 9, so our multiple of 9 had to be at least equal to 1 + { 8 , 9 } + { 0 , 5 } + 0 = { 9 , 10 , 14 , 15 }, and that has to be 9 or 18 with only one digit left to be found with possibilities of { 9-9 , 18-9 , 18-10 , 18-14 , 18-15 } = { 0 , 9 , 8 , 4 , 3 } , in which 0 is the only one suitable to be X1 (with A < 12821), but 10800 doesn't fulfill all the conditions (#6 about the inclusion of either 4 or 5).

For 3), A would end in 25 or 75 and the multiples with 8, 9, 21 & 39 would all end in fives & zero (in 8A/5 case) too, so A would look like this :
1 [X1] [X2] [2 or 7] 5

One of the Xs would need to be 8 or 9, so our multiple of 9 had to be at least equal to 1 + { 8 , 9 } + 0 + { 2 , 7 } + 5 = { 16 , 17 , 21 , 22 }, and that has to be exactly 18 or exactly 27 with no digits left to be found. Since none of the 4 possibilities are equal to neither 18 nor 27, then this third possibility is now an impossibility.

For 4), A would end in 5 and the multiples with 8, 9, 21 & 39 would end in two distinct non-five odd digits & non-zero even digit (in 8A/5 case), so A would look like this :
1 [X1] [X2] [X3] 5
with X1, X2 & X3 being 2 odds and an even in some order. Since X1 + X2 + X3 + 1 + 5 = odd + even + odd + 1 + 5 = even, then our multiple of 9 can only be 18 (36 would be too large considering the known digits of 1 & 5 and the parity involved). One of the Xs would need to be 8 or 9, so our multiple of 9 had to be 1 + { 8 , 9 } + 5 = { 14 , 15 }, and that has to be exactly 18 with two digits left to be found. 18-14 = 1 + 3 for a sum of 2 odd digits and 18-15 = 1 + 2 are the only 2 sums involving two non-zero digits. Our number is now down to this possibilities : { 11385 , 11835 , 11295 , 12195 }. Testing each of these last 4 with a multiple will let's us see which one is the answer we're looking for.

Saya Suka - 3 months ago
Kyle T
May 13, 2019

Its a brute force, sorry I'm not more clever...
For each 5 digit number i, we compute the 4 accompanying numbers, check that they are all 5 digits long then check that they are composed of the same digits

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
for($i=10000;$i<=99999;$i++){
    $arr = array( (8*$i)/5, (9*$i)/5, (21*$i)/5, (39*$i)/5 );
    $i_arr = str_split($i);
    sort($i_arr);
    $continue = false;
    foreach($arr as $a){
        if(strlen($a)!=5){
            $continue = true;
        }
        $a_arr = str_split($a);
        sort($a_arr);
        if($a_arr!==$i_arr){
            $continue = true;
        }
    }
    if(!$continue){
        echo 'answer: '.$i;
        echo '<pre>'.print_r($arr,true).'</pre>';
    }
}
/*
prints:
answer: 12195
Array
(
    [0] => 19512
    [1] => 21951
    [2] => 51219
    [3] => 95121
)
*/
?>

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...