[BACK]Return to sample.pl CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gmp / demos / perl

Annotation of OpenXM_contrib/gmp/demos/perl/sample.pl, Revision 1.1

1.1     ! ohara       1: #!/usr/bin/perl -w
        !             2:
        !             3: # Some sample GMP module operations
        !             4:
        !             5: # Copyright 2001 Free Software Foundation, Inc.
        !             6: #
        !             7: # This file is part of the GNU MP Library.
        !             8: #
        !             9: # The GNU MP Library is free software; you can redistribute it and/or modify
        !            10: # it under the terms of the GNU Lesser General Public License as published
        !            11: # by the Free Software Foundation; either version 2.1 of the License, or (at
        !            12: # your option) any later version.
        !            13: #
        !            14: # The GNU MP Library is distributed in the hope that it will be useful, but
        !            15: # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
        !            16: # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
        !            17: # License for more details.
        !            18: #
        !            19: # You should have received a copy of the GNU Lesser General Public License
        !            20: # along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
        !            21: # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
        !            22: # MA 02111-1307, USA.
        !            23:
        !            24: use strict;
        !            25:
        !            26:
        !            27: use GMP::Mpz qw(:all);
        !            28: print "the 200th fibonacci number is ", fib(200), "\n";
        !            29: print "next prime after 10**30 is (probably) ", nextprime(mpz(10)**30), "\n";
        !            30:
        !            31:
        !            32: use GMP::Mpq qw(:constants);
        !            33: print "the 7th harmonic number is ", 1+1/2+1/3+1/4+1/5+1/6+1/7, "\n";
        !            34: use GMP::Mpq qw(:noconstants);
        !            35:
        !            36:
        !            37: use GMP::Mpf qw(mpf);
        !            38: my $f = mpf(1,180);
        !            39: $f >>= 180;
        !            40: $f += 1;
        !            41: print "a sample mpf is $f\n";

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>