MPU is very strict about getting integers, as it is very easy for Perl to suddenly decide a large number is a float. This is almost always something Very Bad when doing number theory. I chose to have it complain instead of giving subtly wrong results.

One of the problems here is the merit calculation needs to be done using FP logs. This is why, if you look at my gap software, everything is a bigint except the merit calculation, done in a sub that explicitly converts to BigFloats. It's a PITA, and Perl6 / PARI are much nicer in this.

Anyway, $fact*$i could easily overflow (primorial(31)*3e8 is larger than 64-bit). You need to do something like my $fact = Math::BigInt->new(primorial(31)); to force $num to be a bigint. Then the merit calc should be done as a sub that uses Math::BigFloat.


In reply to Re: Odd error message by danaj
in thread Odd error message by robert44444uk

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.