L

Luhn’s Algorithm

Luhn's Algorithm is a checksum formula used to validate identification numbers, particularly credit card numbers.

Luhn’s Algoritmo, also known as the fórmula de Luhn or algoritmo de módulo 10, is a simple checksum formula that is widely used to validate identification numbers, especially credit card numbers. Desarrollado por IBM scientist Hans Peter Luhn in 1954, this algorithm helps to prevent accidental errors in data entry and is employed by various industries to ensure the integrity of numeric identifiers.

El algoritmo funciona realizando los siguientes pasos:

  1. Comenzando desde el dígito más a la derecha, duplica el valor de cada segundo dígito. Si esta duplicación resulta en un número mayor que 9, resta 9 al resultado.
  2. Suma todos los dígitos, tanto los alterados como los no alterados.
  3. If the total modulo 10 is equal to 0, then the number is valid according to Luhn’s Algorithm.

Por ejemplo, considera el número 4539 1488 0343 6467:

  • Duplica cada segundo dígito desde la derecha: 4, 10, 3, 18, 8, 0, 3, 12, 6, 12, 7.
  • Ajusta aquellos mayores que 9: 4, 1, 3, 9, 8, 0, 3, 3, 6, 3, 7.
  • Suma: 4 + 1 + 3 + 9 + 8 + 0 + 3 + 3 + 6 + 3 + 7 = 43.
  • Verifica si 43 módulo 10 es igual a 0: no lo es, por lo que el número no es válido.

Luhn’s Algorithm is particularly useful because it can be easily implemented and is effective in detecting simple errors, such as mistyped digits or transposed numbers. However, it’s important to note that while Luhn’s Algorithm can indicate that a number might be valid, it does not guarantee that the number is legitimate or has not been compromised.

oEmbed (JSON) + /