Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
マイナンバーシェル芸(文字列結合ではなく数値計算でチェックデジットを計算する) のメモ
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
You can’t perform that action at this time.