]> www.ginac.de Git - cln.git/blob - src/integer/algebraic/cl_I_rootp.cc
934d9488c7620f7bbdc1ec1b93a915afffe97d67
[cln.git] / src / integer / algebraic / cl_I_rootp.cc
1 // rootp().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cl_integer.h"
8
9
10 // Implementation.
11
12 #include "cl_I.h"
13
14 // Methode:
15 // Falls x=0 oder x=1: x = x^n -> JA, x als Ergebnis.
16 // Hier also x>1. Suche ein Integer y > 1 mit x=y^n.
17 // Falls n >= integer_length(x): NEIN. (Da y>=2, müßte x>=2^n gelten.)
18 // Hier also n>0 klein...
19
20 cl_boolean rootp (const cl_I& x, uintL n, cl_I* w)
21 {
22         if (eq(x,0) || eq(x,1)) // x=0 oder x=1 ?
23           { *w = x; return cl_true; } // ja -> x als Ergebnis
24         if (n >= integer_length(x))
25           { return cl_false; }
26         return cl_rootp_aux(x,n,w);
27 }