diff options
Diffstat (limited to '016/ch1.pl')
-rwxr-xr-x | 016/ch1.pl | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/016/ch1.pl b/016/ch1.pl new file mode 100755 index 0000000..e5dd577 --- /dev/null +++ b/016/ch1.pl @@ -0,0 +1,17 @@ +#!/usr/bin/env perl +# +# At a party a pie is to be shared by 100 guest. The first guest gets 1% of the +# pie, the second guest gets 2% of the remaining pie, the third gets 3% of the +# remaining pie, the fourth gets 4% and so on. Write a script that figures out +# which guest gets the largest piece of pie. +################################################################################ + +use strict; +use warnings; + +my $guest = 0; +my $sum = 0; + +$sum += ++$guest while $sum <= 100; + +print "Largest piece: ", $guest-1, "\n"; |