Last active
October 12, 2019 17:03
-
-
Save lancew/1b750e81b83963977858ea15dc54b765 to your computer and use it in GitHub Desktop.
Per5->Perl6... next step Raku
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub MAIN($n=100) { | |
my $percentleft = 100; | |
my $biggestpercent = 0; | |
my $guestwithbiggestpercent = 0; | |
for (1..$n) -> $i | |
{ | |
my $pi = $i * $percentleft / 100; # amount for guest i | |
print "guest $i has $pi percent of the pie\n"; | |
if ( $pi > $biggestpercent ) | |
{ | |
$biggestpercent = $pi; | |
$guestwithbiggestpercent = $i; | |
} | |
$percentleft -= $pi; # percentage left over | |
} | |
print "\nguest $guestwithbiggestpercent has biggest percentage of pie: " ~ | |
"$biggestpercent\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment