cancel
Showing results for 
Search instead for 
Did you mean: 

Calculating Luhn Check Digit

Former Member
0 Kudos

<p>I have an 18 digit number and i need a SQL formula in Crystal Reports to calculate the Luhn digit.</p><p>Below is how Luhn is calculated.</p><p>Step 1: Double the value of alternate digits beginning with the first right hand digit.</p><p>e.g 8 6 3 7 5 = 8 12 3 14 5</p><p>Step 2: Add the individual digits compromising the products obtained in Step 1 to each of the unaffected digits in the original number.</p><p>e.g 8 12 3 14 5 = 8123145 (total=24)</p><p>Step 3: Subtract the total obtained in Step 2 from the next higher number ending in 0.</p><p>e.g 24 = 30-24 = 6 (Luhn = 6!)</p><p>Any help here would be fantastic!!</p>

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Is this the same as Mod 10? I did some reading on luhn http://en.wikipedia.org/wiki/Luhn_algorithm  first off this reading says that the luhn calculation is the same as mod 10, in that case you could use "Modulus" in the formula editor of Crystal Reports, under Operators | Arithmatic. However, this gives a different answer to the way you have it calculated. In reading further it seems luhn is used to check validity of a given number that follows a certain set of rules. It says to check validity you divide by 10 and if the result is 0 then the number is valid.
If I follow the instruction in the link the result would be 5, not equaling 0 would indicate false
Im not a mathmatician nor do I calim to fully understand luhn or mod 10 but it would seem something is out of sync here between how its explained in the link above and your post.
At any rate, will the "Modulus" operator work somehow for you?