nationid - v0.6.0
    Preparing search index...

    Function luhnValid

    • Luhn algorithm — ISO/IEC 7812-1.

      Used by: credit cards, CA SIN, FR SIREN/SIRET, IT P.IVA, IL TZ/HP, ZA ID, and several IDs that document the algorithm as "Luhn variant".

      Algorithm:

      1. From the rightmost digit, double every second digit.
      2. If doubling produces a 2-digit number, sum its digits (or subtract 9).
      3. Sum all digits.
      4. Number is valid iff sum is divisible by 10.

      Public-domain mathematical algorithm.

      Parameters

      • digits: string

      Returns boolean