Thanks for the welcome, Athanasius. I like what you did with the number separators (600_851_475_143).

#print Dumper \@result;

I'm curious why this dumps the reference to @result. Is there an advantage to this way of doing it?

Lastly, my run at the problem resulted in this code:

use Modern::Perl '2012'; # "All operators (including basic math operations) are overloaded. use bigint lib => 'Calc, GMP'; use Regexp::Common; use Data::Dumper; use List::Util qw/ max /; use Carp qw/ confess /; $SIG{__DIE__} = sub { confess @_; }; sub big_factors { my $n = shift; my @factors = [ ]; my $d = 2; # ensure $n is an integer if ($n !~ /$RE{num}{real}/) { die "Argument was not a real number."; } while ($n > 1) { while ( 0 == $n % $d) { push @factors, $d; $n /= $d; } $d += 1; if ($d**2 > $n) { if ($n > 1) { push @factors, $n; last; } } } return @factors; } my @result = big_factors(600851475143); say max @result;

In reply to Re^2: List::Util can't find max in array of BigInts by mgatto
in thread List::Utils can't find max in array of BigInts by mgatto

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.