1 public class LuhnVerification { 2 checkNumber(String value)3 static boolean checkNumber(String value) { 4 int result = 0; 5 boolean special = false; 6 for (int i = value.length() - 1; i >= 0; i--) { 7 int v = value.charAt(i) - '0'; 8 if (v < 0 || v > 9) 9 return false; 10 if (special) { 11 v = v * 2; 12 if (v > 9) 13 v = v - 10 + 1; 14 } 15 result += v; 16 special = !special; 17 } 18 System.out.println(result); 19 return result % 10 == 0; 20 } 21 main(String args[])22 public static void main(String args[]) { 23 System.out.println(checkNumber("")); 24 } 25 26 } 27