From e8e7615737b32320ac75a5f88db0e5ca3aa9703e Mon Sep 17 00:00:00 2001 From: Guillermo Ramos Date: Wed, 10 Jul 2019 22:28:50 +0200 Subject: [016#1] --- 016/ch1.pl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 016/ch1.pl (limited to '016/ch1.pl') 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"; -- cgit v1.2.3