in reply to Floating point factorials
Note: After 171>, the script just says "inf", so I cut it off at 170.#!/usr/bin/perl use strict; use warnings; sub fact { my $n = shift; my $result = 1; foreach my $i (1 .. $n) { $result *= $i; } $result; } foreach my $i (1 .. 170) { print "$i! = ", fact($i), "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Floating point factorials
by John M. Dlugosz (Monsignor) on May 14, 2011 at 15:59 UTC |