Giter Site home page Giter Site logo

rakshitha-ks / luhn-algorithm Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 3 KB

The Luhn Algorithm is widely used for error-checking in various applications, such as verifying credit card numbers.

Jupyter Notebook 100.00%
creditcard-validator luhn-algorithm luhn-checksum python3

luhn-algorithm's Introduction

Luhn algorithm

Welcome to Luhn algorithm repository! This project features a modulus 10 algorithm, which is a simple mathematical formula used to validate a user's identification numbers.

Table of Contents

  1. Introduction
  2. Working
  3. Output Preview

Introduction

The Luhn algorithm, also known as the modulus 10 or mod 10 algorithm, is a simple checksum formula used to validate a variety of identification numbers, such as credit card numbers, IMEI numbers, Canadian Social Insurance Numbers.
The LUHN formula was created in the late 1960s by a group of mathematicians. Shortly thereafter, credit card companies adopted it. Because the algorithm is in the public domain, it can be used by anyone.
Most credit cards and many government identification numbers use the algorithm as a simple method of distinguishing valid numbers from mistyped or otherwise incorrect numbers. It was designed to protect against accidental errors, not malicious attacks.

Working

The Luhn algorithm is as follows:

  1. From the right to left, double the value of every second digit; if the product is greater than 9, sum the digits of the products.
  2. Take the sum of all the digits.
  3. If the sum of all the digits is a multiple of 10, then the number is valid; else it is not valid.

Assume an example of an account number "7992739871" that will have a check digit added, making it of the form 7992739871x:

   Account number      7   9  9  2  7  3  9   8  7  1  x  
   Double every other  7  18  9  4  7  6  9  16  7  2  x  
   Sum 2-char digits   7   9  9  4  7  6  9   7  7  2  x  

Preview

luhn_valid

luhn_invalid

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.