blob: 86b5ef3e22f77ac3284c219072615b75a07a00bc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
#!/usr/bin/env perl
#
# Write a script to calculate the value of e, also known as Euler’s number and
# Napier’s constant. Please checkout wiki page for more information.
################################################################################
use strict;
use warnings;
my $ITERS = shift or die "Usage: $0 <iterations>";
my $e = 1;
my $denom = 1;
foreach my $i (1 .. $ITERS) {
$denom *= $i;
$e += 1/$denom;
}
print "$e\n";
|