Skip to content

enes-fullstack/Luhn-Algorithm_Node.js_API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Luhn Algorithm

This project implements the Luhn Algorithm, which is used to validate 16-digit numbers.
It helps prevent transactions with randomly generated or fake credit card numbers.


How the Algorithm Works

The Luhn Algorithm works as follows:

  1. Take a 16-digit number
    Example: 4538 2349 8239 8239

  2. Multiply the first digit by 2

    • If the result is greater than 10, add the digits together.
    • Example: 12 → 1 + 2 = 3
    • If the result is less than 10, use it as-is.
    • Example: 4 × 2 = 8 → result = 8
  3. Write down the second digit as-is

    • Example: 5
  4. Multiply the third digit by 2, and write the fourth digit as-is

    • Repeat this process for all digits.
  5. Sum all the resulting digits

    • Example: Total = 99
  6. Check if the total is divisible by 10

    • If divisible by 10, the number is a valid credit card number according to the Luhn Algorithm.
    • If not divisible by 10, the number cannot be a valid credit card number.

About This Project

  • The 16-digit number entered by the user is validated using the Luhn Algorithm.
  • Based on the algorithm, the project indicates whether the number has the potential to be a valid credit card number.

Note: The Luhn Algorithm only checks the correctness of the digits; it does not verify whether the card is real or active.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published