#!perl -l $_++;$_*=$~--,s/0$//,$_%=1e5while$~+=pop;print$_%10 |
Looping backwards allowed to replace /5/2until%5 thing with s/0+$//.
#!perl -l $_++;$_*=$~--,s/0+$//,$_%=1e5while$~+=pop;print$_%10 |
Some optimizations.
#!perl -l
map{$_/=5,$/=2until$_%5;$=$%1e5*$_}2..pop;print$/2%10
|
#!perl -l
map{$_/=($/=2)&&5until$_%5;$=($%1e5)*$_}1..pop;print$/2%10
|