The Luhn test is used by some credit card companies to distinguish valid credit card numbers from what could be a random selection of digits.

Those companies using credit card numbers that can be validated by the Luhn test have numbers that pass the following test:

 Reverse the order of the digits in the number.
 Take the first, third, ... and every other odd digit in the reversed digits and sum them to form the partial sum s1
 Taking the second, fourth ... and every other even digit in the reversed digits:
 Multiply each digit by two and sum the digits if the answer is greater than nine to form partial sums for the even digits
 Sum the partial sums of the even digits to form s2
 If s1 + s2 ends in zero then the original number is in the form of a valid credit card number as verified by the Luhn test.


For example, if the trial number is 49927398716:

Reverse the digits:
  61789372994
Sum the odd digits:
  6 + 7 + 9 + 7 + 9 + 4 = 42 = s1
The even digits:
    1,  8,  3,  2,  9
  Two times each even digit:
    2, 16,  6,  4, 18
  Sum the digits of each multiplication:
    2,  7,  6,  4,  9
  Sum the last:
    2 + 7 + 6 + 4 + 9 = 28 = s2

s1 + s2 = 70 which ends in zero which means that 49927398716 passes the Luhn test


Task

Write a function/method/procedure/subroutine that will validate a number with the Luhn test, and

use it to validate the following numbers:

   49927398716
   49927398717
   1234567812345678
   1234567812345670



Related tasks

   SEDOL
   ISIN


To run:
Start up.
Test whether "49927398716" will pass the luhn test.
Test whether "49927398717" will pass the luhn test.
Test whether "1234567812345678" will pass the luhn test.
Test whether "1234567812345670" will pass the luhn test.
Wait for the escape key.
Shut down.
 
To test whether a string will pass the luhn test:
Write the string then ": " on the console without advancing.
If the string will pass the luhn test, write "valid" on the console; exit.
Write "invalid" on the console.
 
A sum is a number.
 
To decide if a string will pass the luhn test:
If the string is blank, say no.
Privatize the string.
Reverse the string.
Put 0 into a first sum.
Put 0 into a second sum.
Put 1 into a count.
Slap a rider on the string.
Loop.
If the rider's source is blank, break.
Put the rider's source's first's target into a byte.
If the byte is not any digit, say no.
Convert the byte to a number.
If the count is odd, add the number to the first sum; bump the count; bump the rider; repeat.
Double the number.
If the number is greater than 9, digital root the number.
Add the number to the second sum.
Bump the count. Bump the rider.
Repeat.
If the first sum plus the second sum is evenly divisible by 10, say yes.
Say no.
 
To digital root a number:
Divide the number by 10 giving a quotient and a remainder.
Put the quotient plus the remainder into the number.
 
To convert a byte to a number:
If the byte is any digit, put the byte minus 48 into the number.