Skip to content

Instantly share code, notes, and snippets.

@kshoji
Last active November 10, 2015 07:06
Show Gist options
  • Save kshoji/ded1f2e2b1641c2b0ba5 to your computer and use it in GitHub Desktop.
Save kshoji/ded1f2e2b1641c2b0ba5 to your computer and use it in GitHub Desktop.
有効な個人用マイナンバーを全て列挙するコード
public class MyNumberLister {
public static void main(String[] args) {
for (long i = 0; i < 100000000000L; i++) {
String myNumber = String.format("%011d", i);
int sum = 0;
for (int j = 1; j < 12; j++) {
int digit = Integer.parseInt(myNumber.substring(11 - j, 12 - j));
int multiplier = (j < 7) ? j + 1 : j - 5;
sum += digit * multiplier;
}
int checkDigit = (sum % 11 < 2) ? 0 : 11 - sum % 11;
myNumber += checkDigit;
System.out.println(myNumber);
}
}
}
function myNumberListup() {
for (var i = 0; i < 100000000000; i++) {
var myNumber = ("00000000000" + i).substr(-11);
var sum = 0;
for (var j = 1; j < 12; j++) {
var digit = myNumber.substr(11 - j, 1);
var multiplier = (j < 7) ? j + 1 : j - 5;
sum += digit * multiplier;
}
var checkDigit = (sum % 11 < 2) ? 0 : 11 - sum % 11;
myNumber += checkDigit;
console.log(myNumber);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment