no

# Learn Luhn Formula (mod 10) for Account Number Validation

I. Introduction The Luhn Algorithm is a simple checksum formula used to validate a variety of identification numbers, such as credit card ...

### I. Introduction

The Luhn Algorithm is a simple checksum formula used to validate a variety of identification numbers, such as credit card numbers.

### II. Using the Luhn Algorithm to Validate a PAN or Primary Account Number

1. Double the value of the alternate digits of the PAN beginning with the second digit from the right (the 1st right-hand digit is the check digit).
2. Add the individual digits resulting from Step One above to each of the unaffected (unused) digits of the original PAN.
*If the result from Step One is a two-digit number, add each digit together to obtain a one-digit result for Step Two.
3. The total obtained in Step Two must be a number ending in Zero (10, 20, etc.) for the PAN to be validated
For Example, to validate the PAN 4062001210012106

### III. Here's a Java Code that Checks for a Credit Card Number Validity

```public static boolean isCreditCardValid(String ccNumber) {
int sum = 0;
boolean alternate = false;
for (int i = ccNumber.length() - 1; i >= 0; i--) {
int n = Integer.parseInt(ccNumber.substring(i, i + 1));
if (alternate) {
n *= 2;
if (n > 9) {
n = (n % 10) + 1;
}
}
sum += n;
alternate = !alternate;
}
return (sum % 10 == 0);
}
```

#### Related

computer-science 7437393750921233198