Skip to content

Instantly share code, notes, and snippets.

@kabutz
Created May 5, 2014 08:03
Show Gist options
  • Save kabutz/13ee4e22fc796a469d06 to your computer and use it in GitHub Desktop.
Save kabutz/13ee4e22fc796a469d06 to your computer and use it in GitHub Desktop.
How to validate a Greek Tax Number (AFM)
// From http://www.gsis.gr/gsis/info/gsis_site/Services/Polites/sources.html
// gr.gsis.e7.E7File class
// Apache 2.0 license
public static boolean afmIsValid(String afm) {
int sum = 0;
if (afm.length() != 9)
return false;
for (int i = 0; i < 8; i++)
sum += (afm.charAt(i) - '0') << (8 - i);
return ((afm.charAt(8) - '0') == ((sum % 11) % 10));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment