aboutsummaryrefslogtreecommitdiff
path: root/challenge-021/ruben-westerberg/perl5/ch-1.pl
blob: 669f076aad089eb29bb360bfd5ce28ccd274f0b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env perl

use strict;
use warnings;
use v5.26;
use bignum (a=>100);
#use Math::BigRat;
#compute Euler's number to the nth term
#
my $degree=$ARGV[0]//10;
my $i=1;
my $sum=1;#Math::BigRat->new(1/1);
while ($i <= $degree ) {
	state $fac=1;
	$sum+=1/($fac*=$i++);
}
printf "Eulers constant to $degree terms:\n%s\n",$sum;