Content deleted Content added
add typescript example |
→Java: the algorithm was highly inefficient and not how it is normally written in Java |
||
Line 140:
<syntaxhighlight lang="java" line="1">
public static boolean isValidLuhn(String number) {
int checksum = Character.getNumericValue(number.charAt(number.length() - 1));▼
int total = 0;
boolean even = true;
for (int i =
int digit =
if (
return false;
}
if (even) {
even = !even;
total += digit > 9 ? digit - 9 : digit;
}
return (total
}
</syntaxhighlight>
|