in reply to Reversed long division

I worked out a solution, but the problem is that it prepends to $out instead of appending, so converting $out to a file handle is out.

$in = '67567'; $carry = 126; $out = sprintf('%06d', substr($in, -3, 3, '') * 222 + $carry); while (length($in)) { substr($out, 0, 3, sprintf('%04d', substr($out, 0, 3) + substr($in, -1, 1, '') * 222 )); } $out =~ s/^0+//; print($out, "\n");

You'll need to put some work into reversing it. Show some effort.

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.