File: nextprime.cc

package info (click to toggle)
cln 0.98-7.1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 12,188 kB
  • ctags: 15,282
  • sloc: cpp: 71,545; ansic: 12,015; asm: 8,431; sh: 3,159; makefile: 886; lisp: 64
file content (27 lines) | stat: -rw-r--r-- 590 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// This program prints the smallest probable prime >= x, x being given on the
// command line.

// Every CLN application needs this:
#include <cl_number.h>

// We do I/O.
#include <cl_io.h>

// We work with real numbers and integers.
#include <cl_real.h>
#include <cl_integer.h>

// The function nextprobprime() is part of the number theory package.
#include <cl_numtheory.h>

main (int argc, char* argv[])
{
	if (argc != 2) {
		fprint(cl_stderr, "Usage: nextprime x\n");
		exit(1);
	}
	cl_R x = (cl_R)argv[1];
	cl_I p = nextprobprime(x);
	fprint(cl_stdout, p);
	fprint(cl_stdout, "\n");
}