Skip to content

Instantly share code, notes, and snippets.

@kunst1080
Last active November 7, 2017 14:47
Show Gist options
  • Save kunst1080/3706d19a2bc948611d39ecb490a917ec to your computer and use it in GitHub Desktop.
Save kunst1080/3706d19a2bc948611d39ecb490a917ec to your computer and use it in GitHub Desktop.
マイナンバーシェル芸(文字列結合ではなく数値計算でチェックデジットを計算する) のメモ
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
}'
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