in reply to List::Utils can't find max in array of BigInts
Hello mgatto, and welcome to the Monastery!
From the information given, I cannot reproduce your problem:
#! perl use strict; use warnings; use bigint; use List::Util qw( max ); use Data::Dumper; my @result = prime_factors(600_851_475_143); #print Dumper \@result; print max @result; sub prime_factors { my ($number) = @_; my $divisor = 2; my @factors; while ($number > 1) { if (($number % $divisor) == 0) { push @factors, $divisor; $number /= $divisor; } elsif ($divisor == 2) { ++$divisor; } else { $divisor += 2; } } return @factors; }
Output:
12:58 >perl 609_SoPW.pl 6857 13:00 >
However, the problem you are seeing may be related to the problem I experienced recently with bignum and the range operator: see Strange interaction of bigint and foreach.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: List::Util can't find max in array of BigInts
by mgatto (Novice) on Apr 25, 2013 at 19:33 UTC | |
by Athanasius (Archbishop) on Apr 26, 2013 at 13:01 UTC |