This is an interesting number puzzle:
- A person has 2 bank cards, each with a 4 digit PIN.
- The first PIN is 4 times the second PIN.
- The first PIN is the reverse of the second PIN.
- Find both PINs.
We shall refer the smaller number as N1 and the larger number as N2. The smaller number has to be less than 3000, for if it were 3000 or higher multiplying it by 4 would result in 12000 or higher, which is more than 4 digits.
So, N1 has to begin with 0, 1 or 2. It cannot begin with 1, because that would imply that N2 has to END with 1; there are no multiples of 4 that end with the digit 1. Let us look at the remaining two options.
If N1 begins with 0 (ie it is in the format ‘0—‘) then N2 has to be in the format ‘—0’. For the 4th digit of N2 to be 0, the 4th digit of N1 has to be ‘0’ or ‘5’ (these are the only two digits which result in a number ending in 0 after being multiplied by 4).This implies that N1 has to be ‘0–0’ or ‘0–5’; it cannot be ‘0–5’ because N2 would then become ‘5–0’.
We then have to find the middle two digits. Substituting the digits ’00’ to ’99’ into the format ‘0–0′ we find that the only solution is ’00’, ie the number is ‘0000’. This satisfies the terms of the original question because 0 is indeed 4 time 0 and ‘0000’ is the reverse of ‘0000’, but it is probably not the solution the original setter envisaged.
Let us now look at the case where N1 begins with 2 (‘2—‘); N2 has to be ‘—2’. For the 4th digit of N2 to be 2, the 4th digit of N1 has to be 3 or 8; it cannot be 3 because that would make N2 ‘3–2’ which cannot result from multiplying ‘2–3’ by 4.
So we are now left with ‘2–8’ and ‘8–2′ as the format for the two numbers. Again, substituting the digits ’00’ to ’99’ into the format ‘2–8′ we find that the only solution is ’17’, ie the number is ‘2178’. Multiplying this by 4 results in ‘8172’ which is the reverse of the original number.
I have created a small page with Javascript to solve this:
1<!DOCTYPE html>
2<html>
3 <head>
4 <title>Card Pins Puzzle</title>
5 </head>
6 <body>
7 <h1>The Card Pins Puzzle</h1>
8 <div>
9 <p>A Person has 2 bank cards, each with a 4 digit PIN.</p>
10 <p>The first PIN is 4 times the second PIN, it is also the reverse of the second PIN.</p>
11 <p>Find the first PIN.</p>
12 </div>
13 <div><button onclick="getSolution()">Solution</button></div>
14 <div id="message"></div>
15 <script>
16 function getSolution() {
17 message = document.getElementById("message");
18 for (let i = 0; i < 3000; i++) {
19 j = i.toString();
20 k = (i * 4).toString().split('').reverse().join('');
21 if (j === k) message.innerHTML = message.innerHTML + "<p>" + j + "</p>";
22 }
23 }
24 </script>
25 </body>
26</html>
Line 13 assigns the Javascript code to the button. Line 17 gets the “message” div used to display the results. Line 18 loops from 0 to 2999, creating a string from the number. Line 20 multiplie this number by 4, creates a string from it, then reverses the string. Line 21 inserts the number into the “messagge” div if the two strings are equal. You can access it here.