diff options
author | Andinus <andinus@nand.sh> | 2021-08-11 15:26:15 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2021-08-11 15:26:15 +0530 |
commit | 321825828ac918bad28d0597a8616c6dc9802c3c (patch) | |
tree | 0b8e9cb1012197750eb58e972736319b2a6abac2 /c/grains/src | |
parent | 2979ef790ac5b8f58495e0dd08cafd6a3a2e30a5 (diff) | |
download | exercism-321825828ac918bad28d0597a8616c6dc9802c3c.tar.gz |
Add solved exercises
Diffstat (limited to 'c/grains/src')
-rw-r--r-- | c/grains/src/grains.c | 10 | ||||
-rw-r--r-- | c/grains/src/grains.h | 9 |
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 |