Skip to content

Instantly share code, notes, and snippets.

@barend
Created June 10, 2011 12:44
Show Gist options
  • Save barend/1018771 to your computer and use it in GitHub Desktop.
Save barend/1018771 to your computer and use it in GitHub Desktop.
Burgerservicenummer Elfproef Validator
/** Validate BSN according to http://nl.wikipedia.org/wiki/Burgerservicenummer */
private boolean isValidBSN(int candidate) {
if (candidate <= 9999999 || candidate > 999999999) {
return false;
}
int sum = -1 * candidate % 10;
for (int multiplier = 2; candidate > 0; multiplier++) {
int val = (candidate /= 10) % 10;
sum += multiplier * val;
}
return sum != 0 && sum % 11 == 0;
}
@VosWouter87
Copy link

Interesting that you started with 100000000, because the first years (everyone that transferred from the old system) these numbers had 8 digits. Those numbers got a leading zero when the length of the number was increased to 9 digits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment