Greedy algorithm for Egyptian fractions: Difference between revisions

m
→‎{{header|Perl 6}}: some fixes to roles
(Restored visibility of task description formulae - lost to most browsers in under-tested cosmetic edits of 02:50, 16 August 2016)
m (→‎{{header|Perl 6}}: some fixes to roles)
Line 285:
method gist {
join ' + ',
(self.abs >= 1 ?? "[{self.floor}]" !!if Nilself.abs >= 1),
map {"1/$_"}, self.denominators;
}
Line 291:
my ($x, $y) = self.nude;
$x %= $y;
my @denom = gather ($x, $y) = -$y % $x, $y * take ($y / $x).ceiling
while $x;
}
Line 322:
 
<lang perl6>role Egyptian {
method gist { join ' + ', map {"1/$_"}, self[].list }
method list {
my $sum = 0;
2,392

edits