int lookup[] = { 8, 6, 4, 2, 0, 7, 5, 3, 1, 9, 7, 5, 3, 1, 9, 6, 4, 2, 0 }; int c_fluhn( int n ) { return lookup[ n % 20 ]; }