Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

563680 views
1
#!/usr/bin/perl -w
2
3
# Some sample GMP module operations
4
5
# Copyright 2001, 2004 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., 51 Franklin Street, Fifth Floor, Boston,
22
# MA 02110-1301, USA.
23
24
use strict;
25
26
27
use GMP;
28
print "using GMP module $GMP::VERSION and GMP library ",GMP::version(),"\n";
29
30
31
use GMP::Mpz qw(:all);
32
print "the 200th fibonacci number is ", fib(200), "\n";
33
print "next prime after 10**30 is (probably) ", nextprime(mpz(10)**30), "\n";
34
35
36
use GMP::Mpq qw(:constants);
37
print "the 7th harmonic number is ", 1+1/2+1/3+1/4+1/5+1/6+1/7, "\n";
38
use GMP::Mpq qw(:noconstants);
39
40
41
use GMP::Mpf qw(mpf);
42
my $f = mpf(1,180);
43
$f >>= 180;
44
$f += 1;
45
print "a sample mpf is $f\n";
46
47