summaryrefslogtreecommitdiff
path: root/016/ch1.pl
blob: e5dd577f5540add72d35e08bda12cd999d991a10 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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";