Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trycf/22f8327cd060fca5a25c7ab8a9a22938 to your computer and use it in GitHub Desktop.
Save trycf/22f8327cd060fca5a25c7ab8a9a22938 to your computer and use it in GitHub Desktop.
TryCF Gist
<cfscript>
public numeric function calCheckDigit( string number ) {
var arrTable = [0,9,4,6,8,2,7,1,3,5];
var carry = 0;
var i = 1;
for ( i = 1; i <= len( number ); i++ ) {
// writeOutput((carry + mid( number, i, 1 ) ));
carry = arrTable[ (( carry + mid( number, i, 1 ) ) % 10 ) + 1 ];
}
return ( 10 - carry ) % 10;
}
writeOutput(calCheckDigit("70004152"));
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment