Skip to content

vinayakrit/credit-card-checker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

credit-card-validation

// vinayakrit

// Vinayak Patil

// This code is made of an education purpose to show how Luhn algo. works, no other intend behind this code //have a errorless journey

/* How Algo. works

  1. Double every second digit from right to left. If doubling of a digit results in a two digit number, add up the two digits to get a single-digit number dig=3, 32=6 dig=6, 62=12=>1+2=3

  2. Now add all single-digit result from above add1= 6 + 3 + ....

  3. Add all digits in the odd places from right to left in the card number add2= 9 + 1 + ...

  4. Add add1 & add2 add = add1 + add2

  5. if add%10 = 0 then valid card Luhn says if total sum mod 10 is zero then valid

Ex. step 1: suppose credit card number is 9878945622378945 so number = 78945622378945 doubling of every second digit is 42=8 22=4 72=14 => 1+4=5 82=16 => 1+6=7 52=10 => 1+0=1 92=18 => 1+8=9 32=6 92=18 => 1+8=9

step 2: add1= 8 + 7 + 6 + 4 + 1 + 9 + 5 + 9 = 49

step 3: add2= 5 + 9 + 7 + 2 + 6 + 4 + 8 + 8 = 53

step 4: add= 49 + 53 = 102

step 5: add mod 10 = 102 % 10 = 2 if it is 0 then valid else not valid. Here it is 2 so not valid. */

About

CC validation using java language based on Luhn algorithm

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages