Skip to content

yang-githubb/Luhn-Algo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

Luhn Algorithm Implementation

A Python implementation of the Luhn algorithm for validating credit card numbers.

What is the Luhn Algorithm?

The Luhn algorithm (also known as the modulus 10 or mod 10 algorithm) is a checksum formula used to validate a variety of identification numbers, most commonly credit card numbers. It was designed to protect against accidental errors, not malicious attacks.

Features

  • Validates credit card numbers using the Luhn algorithm
  • Handles card numbers with spaces and hyphens
  • Simple and clean Python implementation

How It Works

The Luhn algorithm follows these steps:

  1. Reverse the card number - Start from the rightmost digit
  2. Sum odd-positioned digits - Add up every other digit (starting with the rightmost)
  3. Double even-positioned digits - Multiply every other digit by 2
  4. Handle double-digit results - If doubling results in a number ≥ 10, add the digits together
  5. Calculate total - Sum all the processed digits
  6. Validate - If the total modulo 10 equals 0, the card number is valid

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages