How do I implement the Luhn algorithm?
I am trying to create a program to validate 10 to 12 digit long number sequences based on the luhn algorithm, but my program keeps on telling me that every number is invalid even though they're not. This number should be valid, but my code doesn't think so: 8112189876 This number should not be valid, which my program agrees with, as it thinks every number is invalid: 8112189875 Here is my code: static void luhn(){ System.out.print("Enter number to validate:\n"); String pnr = input.nextLine(); int length = pnr.length(); int sum = 0; for (int i = 1, pos = length - 1; i < 10; i++, pos--){ char