Taxicab numbers: Difference between revisions

Fix up some internal links
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
(Fix up some internal links)
Line 2,212:
 
=={{header|Phix}}==
{{trans|Perl_6Raku}}
Uses a dictionary to map sum of cubes to either the first/only pair or an integer index into the result set.
Turned out to be a fair bit slower (15s) than I first expected.
Line 2,649:
=={{header|Raku}}==
(formerly Perl 6)
 
This uses a pretty simple search algorithm that doesn't necessarily return the Taxicab numbers in order. Assuming we want all the Taxicab numbers within some range S to N, we'll search until we find N values. When we find the Nth value, we continue to search up to the cube root of the largest Taxicab number found up to that point. That ensures we will find all of them inside the desired range without needing to search arbitrarily or use magic numbers. Defaults to returning the Taxicab numbers from 1 to 25. Pass in a different start and end value if you want some other range.
<lang perl6>constant @cu = (^Inf).map: { .³ }
Line 3,122 ⟶ 3,123:
 
=={{header|Sidef}}==
{{trans|Perl 6Raku}}
<lang ruby>var (start=1, end=25) = ARGV.map{.to_i}...
 
10,327

edits