public static int getLuhnRemainder ( String key ) { int len = key . length ( ) ; int sum = 0 ; for ( int multSeq = len % 2 , ii = 0 ; ii < len ; ii ++ ) { int c = key . charAt ( ii ) - ' ' ; if ( ii % 2 == multSeq ) { c *= 2 ; } sum += ( c / 10 ) + ( c % 10 ) ; } return sum % 10 ; }
Return the luhn remainder for the given key .