$limit=1000; @factorials=(1); foreach(1..$limit) { $factorial=$factorial*$_; push(@factorials,$factorial); }