It is also used to validate IMEI Numbers and National Provider Ind

entifier Number in US.

Lunh Algorithm verify numbers against its check digit (i.e. Last number of credit card). To validate credit card number, it must pass Lunh Algorithm.

**Validate the Credit card using Lunh Alogrithm**

- Step1. Reverse the credit card number e.g.
4211 6880 3434 4563 =3654 4343 0886 1124

- Step 2. Double the every even position digit like.
3 (12) 5 (8) 4 (6) 4 (6) 0 (16) 8 (12) 1 (2) 2 (8)

- Step 3. Make two digit numbers in to a single by adding both digits like (10=1 0=1, 16=(1 6)=7)
3 (12=1 2=3) 5 8 4 6 4 6 0 (16=6 1=7) 8 (12=2 1=3) 1 2 2 8

- Step 4. Get the sum of all numbers and divide them by 10. if the modulus of sum casino online is 0 then credit card number is valid number else credit card number is not valid. e.g.
3 (12=1 2) 5 8 4 6 4 6 0 (16=6 1) 8 (12=2 1) 1 2 2 8=70

mod 70/10 = 0 so this credit card is valid.

**Get check Digit of Credit card number**

- Step 1. Reverse the first 15 digits of credit card number e.g.
4211 6880 3434 456 = 654 4343 0886 1124

- Step 2. Double the every odd position digits. eg.
(12) 5 (8) 4 (6) 4 (6) 0 (16) 8 (12) 1 (2) 2 (8)

- Step 3. Make two digit numbers in to a single by adding both digits like (10=1 0=1, 16=(1 6)=7)
(12=1 2=3) 5 8 4 6 4 6 0 (16=6 1=7) 8 (12=2 1=3) 1 2 2 8

- Step 3. Get the sum of all number and add a digit to the result so that the result is exactly divisible by 10 e.g.
(12=1 2) 5 8 4 6 4 6 0 (16=6 1) 8 (12=2 1) 1 2 2 8=67

In the above exmple we have the sum 67 so I add 3 to it to make it exactly divisible by 10.

so 70 is divisible by 10 and 70-67=3

So 3 is the check digit of this credit card.

Verification of Credit card number in javascript

```
function isCreditCard(CC)
{
if (CC.length > 19)
{
alert("You have entered an invalid card");
return false;
}
sum = 0; mul = 1; l = CC.length;
for (i = 0; i < l; i ) {
digit = CC.substring(l-i-1,l-i);
tproduct = parseInt(digit ,10)*mul;
if (tproduct >= 10)
sum = (tproduct % 10) 1;
else
sum = tproduct;
if (mul == 1)
{
mul ;
}
else
{
mul--;
}
}
if ((sum % 10) == 0)
{
alert("Congrats you enter valid card number");
return true;
}
else
{
alert("You have entered an invalid card");
return false;
}
}
```

]]>