Question 11
Test a16-digit sequence as follows: reverse the digits; leave odd positions unchanged and double even positions; replace any two-digit product by the sum of its digits; then require the total to be divisible by 10. For the exercise sequence $2853\ 00QP\ P003\ 6002$, how many digit pairs $(P,Q)$ with $P\le Q$ pass the test?
Example supplied in the source itself: enter 4634 8932 1298 2767 and reverse it to 7672 8921 2398 4364. The odd-position digits sum to A=7+7+8+2+2+9+4+6=45. Doubling the even-position digits gives 12,4,18,2,6,16,6,8; their digit sum is B=(1+2)+4+(1+8)+2+6+(1+6)+6+8=45. Thus C=A+B=90 ends in 0, so this example passes the check. The source introduces this as the Luhn algorithm for detecting input errors in a long digit sequence.
Example supplied in the source itself: enter 4634 8932 1298 2767 and reverse it to 7672 8921 2398 4364. The odd-position digits sum to A=7+7+8+2+2+9+4+6=45. Doubling the even-position digits gives 12,4,18,2,6,16,6,8; their digit sum is B=(1+2)+4+(1+8)+2+6+(1+6)+6+8=45. Thus C=A+B=90 ends in 0, so this example passes the check. The source introduces this as the Luhn algorithm for detecting input errors in a long digit sequence.