Created
September 19, 2019 08:05
-
-
Save caneryilmaz/7619fc150b6b764f198f4976c77fdde4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private boolean isTCKNCorrect(String id) { | |
if (id == null) return false; | |
if (id.length() != 11) return false; | |
char[] chars = id.toCharArray(); | |
int[] a = new int[11]; | |
for(int i=0; i<11; i++) { | |
a[i] = chars[i] - '0'; | |
} | |
if(a[0] == 0) return false; | |
if(a[10] % 2 == 1) return false; | |
if(((a[0] + a[2] + a[4] + a[6] + a[8]) * 7 - (a[1] + a[3] + a[5] + a[7])) % 10 != a[9]) return false; | |
if((a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] + a[8] + a[9]) % 10 != a[10]) return false; | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment