# For this: http://www.thebigquestions.com/2010/12/21/are-you-smarter-than-google/
my($tg, $tb) = (0, 0);
my $fams = shift @ARGV || 10;
my $N=0;
my @families = map { [0, 0] } (1 .. $fams);
while($tb < @families) {
for(my $i=0; $i<@families; $i++) { # 1000 couples trying for a boy
next if $families[$i][1];
if(rand() < 0.5) { # Girl
$families[$i][0]++;
$tg++;
} else {
$families[$i][1]++;
$tb++;
}
}
printf "Generation %d: girls=%d, boys=%d, ratio=%d%%\n", ++$N, $tg, $tb, 100 * ($tg / ($tg + $tb));
}