Last active
November 10, 2015 07:06
-
-
Save kshoji/ded1f2e2b1641c2b0ba5 to your computer and use it in GitHub Desktop.
有効な個人用マイナンバーを全て列挙するコード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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