Another question to Sisyphus

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

•  Subject
• Author
• Posted on

Here is a little program that compares
if m^n < n!
The problem is that it hangs out. No matter if I use bignum.
It appears related with the division of big numbers.

#!/usr/local/bin/perl -w

# use bignum;
\$last=2;

for \$m (2..1000){
for \$n (\$last..10000){
\$left = \$m**\$n;
\$rigth=1;
for \$i (2..\$n){
\$rigth*=\$i;
}
if (\$left<\$rigth){
print "\$m \$n n/m=", \$n/\$m, "\n";
\$last=\$n+1;
last;
}
}
}

__END__

PD: The n/m ratio seems to tend to 'e' number,
which is not avaible from perl like pi

--
http://www.telecable.es/personales/gamo /
perl -E 'say 111_111_111**2;'

Re: Another question to Sisyphus

gamo wrote:

e is available directly.

[mysys]: perl -le 'print exp(1)';
2.71828182845905

--
Just because I've written it doesn't mean that
either you or I have to believe it.

Re: Another question to Sisyphus

On Mon, 11 Feb 2008, Big and Blue wrote:

Ooops! That's rigth, e^1=e
My head was out of service.

So, in the original problem the last sentence I could get is

__END__
645 1749 ...
646 1752 n/m-e=-0.00620752505347248011

and that's all... there are no more printouts

Thank you. Best regards,

--
http://www.telecable.es/personales/gamo /
perl -E 'say 111_111_111**2;'

Re: Another question to Sisyphus

If you want to evaluate e to greater precision, I suggest (plug)
something like the following (which prints out a 10000-bit value of
e):

use warnings;
use strict;
use Math::MPFR qw(:mpfr);

my \$precision = 10000; # bits
Rmpfr_set_default_prec(\$precision);

my \$unity = Math::MPFR->new(1);
my \$e = Math::MPFR->new();

Rmpfr_exp(\$e, \$unity, GMP_RNDN);
print \$e, "\n";

__END__

Cheers,
Rob