robert44444uk has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks A happy new year to you all. I have a small problem, the following script works well with say primorial(47) but fails on primorial(53). Is there a workaround?

#!/usr/bin/env perl use warnings; use strict; use Math::BigFloat lib=>"GMP"; use Math::GMPz; use Math::Prime::Util qw/:all/; my $fact = Math::GMPz->new(primorial(53)); print "$fact\n";

I get the response: C:\perl>test1.pl Inappropriate argument supplied to new() at C:/Strawberry/perl/site/lib/Math/GMP z.pm line 197.

Replies are listed 'Best First'.
Re: Too big?
by danaj (Friar) on Jan 02, 2016 at 09:50 UTC

    primorial returns either a native int or a Math::BigInt object, depending on size. Math::GMPz's new() doesn't like Math::BigInt objects.

    One workaround is adding "". before primorial, which will force it into a string regardless of the type. E.g. say Math::GMPz->new("".primorial(53));

      Many thanks danaj - fix works!