Greedy algorithm for Egyptian fractions: Difference between revisions
Greedy algorithm for Egyptian fractions (view source)
Revision as of 00:27, 20 November 2016
, 7 years ago→{{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) |
SqrtNegInf (talk | contribs) m (→{{header|Perl 6}}: some fixes to roles) |
||
Line 285:
method gist {
join ' + ',
(
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
method list {
my $sum = 0;
|