Skip to main content

Luhn Formula or Luhn Algorithm

I created this custom function based on a comment for the IDEA group on Linkedin, it based on the explanation posted below.  I have only been able to test it on Canadian Social Insurance Numbers so if anyone else has number that use this algorithm I would appreciate if you could test it and post where it work.

This function will return a 1 if the identification number adhere to the Luhn Formula else it will return 0 if it is false.

The Luhn algorithm or Luhn formula, also known as the "modulus 10" or "mod 10" algorithm, is a simple check-sum formula used to validate a variety of identification numbers, such as credit card numbers, IMEI numbers, National Provider Identifier numbers in US and Canadian Social Insurance Numbers. It was created by IBM scientist Hans Peter Luhn and described in U.S. Patent No. 2,950,048, filed on January 6, 1954, and granted on August 23, 1960.

The Luhn algorithm will detect any single-digit error, as well as almost all transpositions of adjacent digits. It will not, however, detect transposition of the two-digit sequence 09 to 90 (or vice versa). It will detect 7 of the 10 possible twin errors (it will not detect 22 ↔ 55, 33 ↔ 66 or 44 ↔ 77).

Source: http://en.wikipedia.org/wiki/Luhn_algorithm

Note: The custom function was updated on Jan 24, 2013 as it wasn't handling numbers that end in 0 properly.  It does now.  Anyone who has previously downloaded it should redownload.

aveenm293 Mon, 02/18/2013 - 02:59

Hi Brain
I currently use IDEA 8.5. Will I be able to use this function here and if so how?
Thank you
Regards
Aveen
 
 

Brian Element Mon, 02/18/2013 - 07:15

Hi Aveen,

You shouldn't have any problems using it in 8.5.  What you need to do is download it to your harddrive and open up IDEA.  In IDEA go to the equation editor, you can do this by selecting criteria.  In the equation editor you will have an icon that looks like this #, select it and this bring up the Custom Functions window.  From there select import and find the LuhnFormula.ideafunc file that you saved.  It should now be listed as a function.  Exit out of the custom functions dialog and you will have access to using this funciton by type #LuhnFormula or clicking on the + next to the Custom Functions in the function list and selecting it there.

Let me know if that is not clear or you need any further info.