Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
multi sub floyds-triangle(1 --> List) { 1 .. 1, }
multi sub floyds-triangle(Int:D $n where * > 1 --> List) {
my $nth-triangle-number = $n * ($n + 1) div 2;
return floyds-triangle2($n - 1), $nth-triangle-number - $n ^.. $nth-triangle-number;
}
say floyds-triangle(5);
# (((((1..1) 1^..3) 3^..6) 6^..10) 10^..15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.