Heronian triangles: Difference between revisions
Content added Content deleted
m (→using SQRT table: updated a comment in the REXX section header) |
SqrtNegInf (talk | contribs) m (→{{header|Perl 6}}: added .race for concurrency) |
||
Line 3,261: | Line 3,261: | ||
=={{header|Perl 6}}== |
=={{header|Perl 6}}== |
||
{{works with| |
{{works with|Rakudo|2018.09}} |
||
<lang perl6>sub hero($a, $b, $c) { |
<lang perl6>sub hero($a, $b, $c) { |
||
my $s = ($a + $b + $c) / 2; |
my $s = ($a + $b + $c) / 2; |
||
($s * ($s - $a) * ($s - $b) * ($s - $c)).sqrt; |
|||
$a2.sqrt; |
|||
} |
} |
||
Line 3,285: | Line 3,284: | ||
sub MAIN ($maxside = 200, $first = 10, $witharea = 210) { |
sub MAIN ($maxside = 200, $first = 10, $witharea = 210) { |
||
my @h |
my @h; |
||
(1 .. $maxside).race.map: -> $c { |
|||
for 1 .. $c -> $b { |
|||
for $c - $b + 1 .. $b -> $a { |
|||
if primitive-heronian-area($a,$b,$c) -> $area { |
|||
@h.push: [$area, $a+$b+$c, $c, $b, $a]; |
|||
} |
|||
} |
} |
||
} |
} |
||
} |
} |
||
} |
|||
@h = @h.sort; |
|||
say "Primitive Heronian triangles with sides up to $maxside: ", +@h; |
say "Primitive Heronian triangles with sides up to $maxside: ", +@h; |
||