# When Raffi met the Queen

My friend Raffi likes to tell the story of his trip to London, from more than twenty years ago. When he was visiting Buckingham Palace, he suddenly bumped into Queen Elizabeth II.

The Queen was not amused and asked: "And who are you, Sir?"
To which Raffi quick-wittedly answered: "I? Raffi, Maaaam!"
Raffi always stresses that he said "Maaaam" with a long, stretched, quadrupled "aaaa" in the middle.

Raffi later turned his adventure into a cryptarithm:

   I x RAFFI = MAAAAM


Each letter represents a unique digit.

If we multiply the 5-digit number $RAFFI$ by a single-digit $I$, then the resulting 6-digit number $MAAAAM$ lies below $100000*I$. Hence its starting digit $M$ is smaller than $I$:

(1). The digits $M$ and $I$ satisfy $M<I$.

The last digit $M$ of $MAAAAM$ coincides with the last digit of $I^2$. Testing $I=0,1,2,3,4,5,6,7,8,9$ yields $M=0,1,4,9,6,5,6,9,4,1$. Combining this with $M<I$ from (1), we conclude:

(2). Either (2a) $I=8$ and $M=4$, or (2b) $I=9$ and $M=1$.

Let us get rid of case (2b): In this case $R\ge2$, as digit $1$ is already blocked by $M=1$. Hence $MAAAAM=I*RAFFI>9*20000=180000$, which together with $M=1$ implies $A=8$. But then $MAAAAM=188881$ is not divisible by $I=9$; a contradiction.

So only case (2a) with $I=8$ and $M=4$ remains. Since $MAAAAM$ is a multiple of $I=8$, also its last three digits $AAM$ are a multiple of $8$. Out of the numbers $004,114,224,334,554,664,774,994$, only $224$ and $664$ work. These two options $A=2$ and $A=6$ yield for $RAFFI=MAAAAM/8$ the respective values $52778$ (good) and $58333$ (bad). We summarize:

$8*52778=422224$ is the unique solution to Raffi's cryptarithm.

A = 2
F = 7
I = 8
M = 4
R = 5

Proof:

$52778 * 8 = 422224$

Explanation:

$I != 1$, because then $MAAAAM = RAFFI$
$I != 2$ or $3$, because $I*I$ should be more than 10(otherwise we get that $F*I=A$ twice and then $A*I=A$, so in this case $I=1$
Also, $I != 5$ and $I != 6$, because $5^2 = 25$ and $6^2 = 36$, so that would make $I = A$
Then I only had 4 possible values for $I$: $4, 7, 8, 9$
Then I had to find $I$ so that
$(I^2)MOD10 = M$
$(F*I)MOD10 + I^2/10 = A$
$(F*I)MOD10 + (F*I+(I^2)MOD10)/10 = A$
From here we can see that $I^2/10 = (F*I+(I^2)MOD10)/10$, so if:
$I=4$ THEN $1 = (4F+6)/10$ ==> $F=1$
$I=7$ THEN $4 = (7F+9)/10$ ==> $F=31/7$
$I=8$ THEN $6 = (8F+4)/10$ ==> $F=7$
$I=9$ THEN $8 = (9F+1)/10$ ==> $F=79/9$
And because each letter represents only 1 digit, we can assume that $I=4$ or $I=8$.
If $I=4$, then $M=6$. Then we have to find $F$ that will give the following: $(F*I+(I^2)MOD10)MOD10=A$ and $(F*I+(F*I+(I^2)MOD10)/10)MOD10=A$
Because $I=4$ and $M=6$, $F$ can be anything but $4, 6$.
Also, $F*I+(I^2)MOD10>10$, so $4F+1>10$ ==> $F4>=9$ ==> $F>9/4$ ==> $F>=3$. Now we can inspect each possibility:
$F=3$ ==> $13MOD10=3$, $(12 + 13/10)MOD10 = 5$, $5!=3$. Next:
$F=5$ ==> $21MOD10=1$, $(20 + 21/10)MOD10 = 2$, $1!=2$. Next:
$F=7$ ==> $36MOD10=6$, $(35 + 36/10)MOD10 = 8$, $6!=8$. Next:
$F=8$ ==> $41MOD10=1$, $(40 + 41/10)MOD10 = 4$, $1!=4$. Next:
$F=9$ ==> $46MOD10=6$, $(45 + 46/10)MOD10 = 9$, $6!=9$. So $I!=4$.
Then probably $I=8$. That means that $M=4$ and $F*I+(I^2)MOD10>10$ ==> $8F+4>10$ ==> $8F>6$ ==> $F>=1$
$F=1$ ==> $12MOD10=2$, $(8+ 12/10)MOD10 = 9$, $2!=9$. Next:
$F=2$ ==> $17MOD10=7$, $(16 + 17/10)MOD10 = 7$, $7=7$, so $F=7$.
Substitute $I=8$, $M=4$ and $F=7$ in the formula:
$RA778 * 8 = 4AAAA4$. From here we can find $A$:
$A = (7 * 8 + (8*8)/10)MOD10 = 2$
Now that we know everything except for $R$, we can simply use calculator:
$422224 / 8 = 52778$, so $R=5$

• what's the reason for the downvotes? – Novarg Feb 25 '15 at 20:19