]> www.ginac.de Git - cln.git/blob - src/numtheory/cl_nt_nextprobprime.cc
Make @exec_prefix@ usable in shell scripts.
[cln.git] / src / numtheory / cl_nt_nextprobprime.cc
1 // nextprobprime().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cl_numtheory.h"
8
9
10 // Implementation.
11
12 #include "cl_real.h"
13
14 const cl_I nextprobprime (const cl_R& x)
15 {
16         if (minusp(x))
17                 return 2;
18         // Now x >= 0.
19         var cl_I n = ceiling1(x);
20         if (n <= 2)
21                 return 2;
22         // Now n>=3.
23         if (evenp(n))
24                 n = n+1;
25         // Now n>=3 odd.
26         loop {
27                 if (isprobprime(n))
28                         return n;
29                 n = n+2;
30         }
31 }