]> www.ginac.de Git - cln.git/blob - src/numtheory/cl_nt_nextprobprime.cc
* All Files have been modified for inclusion of namespace cln;
[cln.git] / src / numtheory / cl_nt_nextprobprime.cc
1 // nextprobprime().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cln/numtheory.h"
8
9
10 // Implementation.
11
12 #include "cln/real.h"
13
14 namespace cln {
15
16 const cl_I nextprobprime (const cl_R& x)
17 {
18         if (minusp(x))
19                 return 2;
20         // Now x >= 0.
21         var cl_I n = ceiling1(x);
22         if (n <= 2)
23                 return 2;
24         // Now n>=3.
25         if (evenp(n))
26                 n = n+1;
27         // Now n>=3 odd.
28         loop {
29                 if (isprobprime(n))
30                         return n;
31                 n = n+2;
32         }
33 }
34
35 }  // namespace cln