Last active
November 7, 2017 14:47
-
-
Save kunst1080/3706d19a2bc948611d39ecb490a917ec 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
seq 1 99999999999 | awk '{ | |
for(i=1;i<=11;i++){ | |
a=int($0/(10^(i-1))); | |
b=a-int(a/10)*10; | |
if(i<=6){ | |
sum+=b*(i+1) | |
} else { | |
sum+=b*(i-5) | |
} | |
}; | |
r=sum%11; | |
if(r==0||r==1){ | |
cd=0 | |
}else{ | |
cd=11-r | |
} | |
printf "%011d\n", $0*10+cd | |
}' |
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
seq 1 99999999999 | awk '{for(i=1;i<=11;i++){a=int($0/(10^(i-1)));b=a-int(a/10)*10;if(i<=6){sum+=b*(i+1)}else{sum+=b*(i-5)}};r=sum%11;if(r==0||r==1){cd=0}else{cd=11-r}printf "%011d\n", $0*10+cd}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment