MCPcopy Create free account
hub / github.com/Gecode/gecode / cnroot

Function cnroot

test/int/arithmetic.cpp:325–338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

323 }
324
325 int cnroot(int n, int x) {
326 if (x < 2)
327 return x;
328 /*
329 * We look for u such that: (u-1)^n < x <= u^n
330 */
331 long long int l = 1;
332 long long int u = x;
333 do {
334 long long int m = (l + u) >> 1;
335 if (powle(n,m,x)) l=m; else u=m;
336 } while (l+1 < u);
337 return static_cast<int>(u);
338 }
339
340 /// %Test for nroot constraint
341 class NrootXY : public Test {

Callers 1

solutionMethod · 0.85

Calls 1

powleFunction · 0.85

Tested by

no test coverage detected