Skip to content

Instantly share code, notes, and snippets.

@Ugrend
Created May 11, 2018 05:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save Ugrend/09890dbc7a049651d470d1f8b6b73e1a to your computer and use it in GitHub Desktop.
Save Ugrend/09890dbc7a049651d470d1f8b6b73e1a to your computer and use it in GitHub Desktop.
Random Medicare Card Generator
//Reference: http://www.clearwater.com.au/code/provider
const randomMedicareNumber = ()=>{
let sum = Math.floor(Math.random() * 5) +2;
const weights = [1, 3, 7, 9, 1, 3, 7, 9];
let num = [sum]
for(let i = 0 ; i < 7 ; i++){
let n = Math.floor(Math.random()*10)
sum += n * weights[i+1];
num.push(n)
}
num.push(sum % 10)
return num.join('') + '1/1';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment