summary refs log tree commit diff stats
path: root/c/grains/src
diff options
context:
space:
mode:
Diffstat (limited to 'c/grains/src')
-rw-r--r--c/grains/src/grains.c10
-rw-r--r--c/grains/src/grains.h9
2 files changed, 19 insertions, 0 deletions
diff --git a/c/grains/src/grains.c b/c/grains/src/grains.c
new file mode 100644
index 0000000..b169dcf
--- /dev/null
+++ b/c/grains/src/grains.c
@@ -0,0 +1,10 @@
+#include "grains.h"
+
+uint64_t square(uint8_t index) {
+    if (0 < index && index <= 64)
+        return 1ULL << (index - 1);
+    return 0;
+}
+uint64_t total(void) {
+    return ((1ULL << 63) << 1) - 1;
+}
diff --git a/c/grains/src/grains.h b/c/grains/src/grains.h
new file mode 100644
index 0000000..ed53556
--- /dev/null
+++ b/c/grains/src/grains.h
@@ -0,0 +1,9 @@
+#ifndef GRAINS_H
+#define GRAINS_H
+
+#include <stdint.h>
+
+uint64_t square(uint8_t index);
+uint64_t total(void);
+
+#endif