Luhn Algorithm Calculator

Validate credit card numbers and generate check digits using the Luhn algorithm

Luhn Algorithm Calculator

Validate a complete number with check digit

Enter the complete number including the check digit

Please enter a valid number (digits only)

Example Calculation

Example: Validate 23459034

Number: 23459034

Digits to process: 2345903 (excluding last digit 4)

Check digit: 4 (last digit)

Step-by-Step

1. Working right to left: 2 3 4 5 9 0 3

2. Double every 2nd digit: 4 3 8 5 18 0 6

3. If ≥10, subtract 9: 4 3 8 5 9 0 6

4. Sum: 4+3+8+5+9+0+6 = 35

5. Check digit: (10-(35%10))%10 = 5

Result: 5 ≠ 4, so invalid

Luhn Algorithm Steps

1

Start from Right

Work from right to left

Exclude the check digit

2

Double Every 2nd

Double every second digit

Starting from the rightmost

3

Subtract 9

If doubled digit ≥ 10

Subtract 9 from result

4

Sum & Mod 10

Sum all digits

Take modulo 10 for check digit

Quick Tips

Used for credit card validation

Detects single-digit errors

Cannot detect 22↔55, 33↔66, 44↔77

Also known as mod 10 algorithm

Understanding the Luhn Algorithm

What is the Luhn Algorithm?

The Luhn algorithm, also known as the mod 10 algorithm, is a checksum formula used to validate various identification numbers including credit card numbers, IMEI numbers, and Canadian Social Insurance Numbers. It was created by Hans Peter Luhn, a German computer scientist.

How It Works

  • Processes digits from right to left
  • Doubles every second digit
  • Subtracts 9 if doubled digit ≥ 10
  • Sums all processed digits
  • Check digit makes total divisible by 10

Mathematical Formula

Check Digit = (10 - (sum mod 10)) mod 10

Where sum is the total of all processed digits

Applications

  • Credit card number validation
  • IMEI number verification
  • Gift card number generation
  • Canadian Social Insurance Numbers

Detailed Example: Credit Card Validation

Example Number: 4532015112830366

Step 1: Remove check digit (6)

453201511283036

Step 2: Double every 2nd digit from right

8 5 6 2 0 2 10 1 2 2 16 3 0 7 12

Step 3: Subtract 9 if ≥ 10

8 5 6 2 0 2 1 1 2 2 7 3 0 7 3

Step 4: Sum all digits

8+5+6+2+0+2+1+1+2+2+7+3+0+7+3 = 49

Step 5: Calculate check digit

(10 - (49 mod 10)) mod 10 = 1

Validation Result

❌ Invalid Number

Provided check digit: 6

Calculated check digit: 1

Since 6 ≠ 1, this number fails Luhn validation.

Correct number would be: 4532015112830361

Note: Passing Luhn validation doesn't guarantee the number corresponds to an actual credit card account - it only confirms the number follows the correct mathematical pattern.