in reply to Re: Egyptian fractions (Golf Anyone?)
in thread Egyptian fractions
Update: changing the entire structure to a C-style for-loop saves 2 chars, so this gives me a 79-char solution:$ perl -e '($n,$d)=split"/",pop;{1while++$x<$d/$n;warn"1/$x\n";$n=$n*$ +x-$d;$d*=$x;redo if$n}' 18/20 1/2 1/3 1/15
for(($n,$d)=split"/",pop;$n;){1while++$x<$d/$n;warn"1/$x\n";$n=$n*$x-$ +d;$d*=$x}
blokhead
|
---|