Skip to content

Instantly share code, notes, and snippets.

@jonasbits
Created January 6, 2014 00:45
Show Gist options
  • Save jonasbits/8276285 to your computer and use it in GitHub Desktop.
Save jonasbits/8276285 to your computer and use it in GitHub Desktop.
in sweden everybody have a number, and that number have a checkdigit at the end that is based on http://en.wikipedia.org/wiki/Luhn_algorithm
var luhn10 = function(a,b,c,d,e) {
for(d = +a[b = a.length-1], e=0; b--;)
c = +a[b], d += ++e % 2 ? 2 * c % 10 + (c > 4) : c;
return (d%10===0);
};
@jonasbits
Copy link
Author

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