aboutsummaryrefslogtreecommitdiff
path: root/src/utils/math.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/math.h')
-rw-r--r--src/utils/math.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/utils/math.h b/src/utils/math.h
index 21fc60b..a9d9b85 100644
--- a/src/utils/math.h
+++ b/src/utils/math.h
@@ -10,6 +10,7 @@ STATIC void indextoperm(int64_t, size_t n, uint8_t [n]);
10STATIC int permsign(size_t n, const uint8_t [n]); 10STATIC int permsign(size_t n, const uint8_t [n]);
11STATIC int64_t digitstosumzero(size_t n, const uint8_t [n], uint8_t); 11STATIC int64_t digitstosumzero(size_t n, const uint8_t [n], uint8_t);
12STATIC void sumzerotodigits(int64_t, size_t n, uint8_t, uint8_t [n]); 12STATIC void sumzerotodigits(int64_t, size_t n, uint8_t, uint8_t [n]);
13STATIC double intpow(double, uint64_t);
13 14
14STATIC int64_t 15STATIC int64_t
15factorial(int64_t n) 16factorial(int64_t n)
@@ -183,3 +184,16 @@ sumzerotodigits(int64_t d, size_t n, uint8_t b, uint8_t a[n])
183sumzerotodigits_error: 184sumzerotodigits_error:
184 memset(a, UINT8_ERROR, n); 185 memset(a, UINT8_ERROR, n);
185} 186}
187
188STATIC double
189intpow(double b, uint64_t e)
190{
191 double r;
192
193 if (e == 0)
194 return 1;
195
196 r = intpow(b, e/2);
197
198 return e % 2 == 0 ? r * r : b * r * r;
199}

Generated with cgit - Back to sebastiano.tronto.net