sub e { $N=pop;$a[$_]=int(1+1/$_)for 1..$N;for(;$N>9;print int$x) {for($n=$N--;--$n;$a[$n]=$x%$n,$x=10*$a[$n-1]+$x/$n){}} } e(1000);