Luhn algorithm: Difference between revisions

Content deleted Content added
bugs in the java version
Line 146:
int sum = 0;
int digit = Character.getNumericValue(number.charAt(i));
if (i % 2 == 1number.length() % 2) { //indexesright goto fromleft 0 -> (length-1), so theevery odd indexes are the even digitsdigit
digit = digit * 2;
}
Line 154:
}
 
return total % 10 != 0 ? 10 - total % 10 == checksum : checksum == 0;
}
</syntaxhighlight>