Click here to get back home

Another question to Sisyphus

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Another question to Sisyphus gamo 02-11-2008
Posted by gamo on February 11, 2008, 10:44 am
Please log in for more thread options

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;'

Posted by Big and Blue on February 11, 2008, 4:11 pm
Please log in for more thread options
gamo wrote:

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

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.

Posted by gamo on February 12, 2008, 3:35 am
Please log in for more thread options
On Mon, 11 Feb 2008, Big and Blue wrote:

> gamo wrote:
>
> > PD: The n/m ratio seems to tend to 'e' number,
> > which is not avaible from perl like pi
>
> e is available directly.
>
> [mysys]: perl -le 'print exp(1)';
> 2.71828182845905

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,

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

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

Posted by sisyphus on February 12, 2008, 8:47 am
Please log in for more thread options
> On Mon, 11 Feb 2008, Big and Blue wrote:
> > gamo wrote:
>
> > > PD: The n/m ratio seems to tend to 'e' number,
> > > which is not avaible from perl like pi
>
> > =A0 =A0e is available directly.
>
> > [mysys]: perl -le 'print exp(1)';
> > 2.71828182845905
>
> Ooops! That's rigth, e^1=3De
> 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=3D-0.00620752505347248011
>
> and that's all... there are no more printouts =A0
>
> Thank you. Best regards,
>
>
>
> > --
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0Just because I've written it doesn't mean tha=
t
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 either you or I have to believe it.
>
> --http://www.telecable.es/personales/gamo/
> perl -E 'say 111_111_111**2;'

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 =3D 10000; # bits
Rmpfr_set_default_prec($precision);

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

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

__END__

Cheers,
Rob


Similar ThreadsPosted
Question to Sisyphus December 21, 2007, 6:42 am
DBI question November 5, 2004, 4:28 pm
Newbie Question January 3, 2005, 4:11 pm
LWP question on windows98 October 7, 2004, 8:19 pm
Question to WIN32::OLE October 14, 2004, 11:34 am
Simple question September 15, 2005, 4:17 am
Getopt::Std question September 7, 2005, 9:42 am
Question regarding databases.. November 18, 2005, 9:41 am
Module Question October 25, 2004, 11:42 am
A question of name space October 31, 2004, 2:55 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap