#!/usr/local/bin/perl 
# $Id: random.perl,v 1.13 2001/05/08 01:51:39 doug Exp $
# http://www.bagley.org/~doug/shootout/

use strict;

use constant IM => 139968;
use constant IA => 3877;
use constant IC => 29573;

my $LAST = 42;
sub gen_random { ($_[0] * ($LAST = ($LAST * IA + IC) % IM)) / IM }

my $result = 0;
my $N = $ARGV[0] || 1;
while ($N--) {
    $result = &gen_random(100);
}
printf "%.9f\n", $result;