Skip to Content
author's profile photo Former Member
Former Member

Calculating Luhn Check Digit

<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>

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Sep 08, 2006 at 01:44 AM

    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?

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.