A bit of conjuring from Augustus de Morgan1:
Think of a one-digit number and remember it. (boundaries included, e.g. $$4$$).
Write down a number of any length: (e.g. $$8392017483$$).
Determine the number that you obtain by switching every pair of consecutive digits of the number from step 2. If the number from step 2 has an odd number of digits, then the last digit of the number from step 2 is also the last digit of the number in step 3. For example, the current number from step 2 provides the number $$3829104738$$.
Determine the number that you obtain when subtracting the smallest numbers from step 2 and step 3 from the largest. The example number from step 2 then produces as a result the number $$8392017483 - 3829104738 = 4562912745$$.
Count the number of characters in the name of your father or mother, the name of your birth country, and the name of your favorite actor or artist and add them together. For example, the names Arnold, Canada and Eddy Vedder have a total of 23 characters (the space in the name of the artist was also counted as a character).
Multiply the number you obtained in step 5 with four and its
reverse by 5. Add these together, plus the number from step 1. Based
on the examples we have given above, we obtain the number $$23 \times
4 + 32 \times 5 + 4 = 256$$.
Form the number by putting the figures of the numbers from step 4 and step 6 in a row. On the basis of the examples that we have given above, we obtain as a result the number $$4562912745256$$.
With just the visible figure from the last step, it is perfectly possible
to trace the number from step 1. This is possible by adding up the digits
of the number. Keep repeating this procedure until the result is a number
consisting of one digit. The number that results from the above examples
provides the following sums: \[ \begin{eqnarray*} 4 + 5 + 6 + 2 + 9 + 1 +
2 + 7 + 4 + 5 + 2 + 5 + 6 &=& 58 \\ 5 + 8 &=& 13
\\ 1 + 3 &=& 4 \end{eqnarray*} \] Indeed, that results in the
number from step 1.
It works because all multiples of 9 eventually produce 9 when their digits
are added as above. The procedure asks you to create two multiples of 9
(in steps 4 and 6) and to combine their digits and add your own. Adding
the digits will thus yield 9 plus the number chosen (here, 13), and of
course adding those digits will yield the number itself. The
business with the father's first name, etc., is just smoke — any
numbers can be used in those positions. The calculation of step 6 will be
always result in a multiple of 9.
The input consists of 5 lines with the following information:
a number between 1 and 9, boundaries included (step 1)
an arbitrary natural number (step 2)
the name of a father or mother (step 5)
the name of a country of birth (Step 5)
the name of an actor or artist (step 5)
The first line of the output consists of the number you obtain in Step 7 by applying the trick to the values given in the input. A number is written on a new line each time that you add up the digits of the previous number. This procedure ends when the last number that was issued contains only one digit.
Input:
4
8392017483
Arnold
Canada
Eddy Vedder
Output:
4562912745256
58
13
4