]> www.ginac.de Git - cln.git/blob - examples/nextprime.cc
Initial revision
[cln.git] / examples / nextprime.cc
1 // This program prints the smallest probable prime >= x, x being given on the
2 // command line.
3
4 // We work with real numbers and integers.
5 #include <cl_real.h>
6 #include <cl_integer.h>
7
8 // We do I/O.
9 #include <cl_io.h>
10 #include <cl_integer_io.h>
11
12 // The function nextprobprime() is part of the number theory package.
13 #include <cl_numtheory.h>
14
15 int main (int argc, char* argv[])
16 {
17         if (argc != 2) {
18                 fprint(cl_stderr, "Usage: nextprime x\n");
19                 exit(1);
20         }
21         cl_R x = (cl_R)argv[1];
22         cl_I p = nextprobprime(x);
23         fprint(cl_stdout, p);
24         fprint(cl_stdout, "\n");
25 }