diff options
author | Guillermo Ramos | 2019-07-10 22:28:50 +0200 |
---|---|---|
committer | Guillermo Ramos | 2019-07-10 22:28:50 +0200 |
commit | e8e7615737b32320ac75a5f88db0e5ca3aa9703e (patch) | |
tree | 2bdea22aad08c735a66a0e2fc5c822eebfa139ee /016 | |
parent | 20182e2e72d7bc6956faf6acc5e8d52eff64b3a9 (diff) | |
download | perlweekly-e8e7615737b32320ac75a5f88db0e5ca3aa9703e.tar.gz |
[016#1]
Diffstat (limited to '016')
-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"; |