exercism/c/grains/grains.c

21 lines
312 B
C
Raw Normal View History

2024-06-09 11:52:24 -04:00
#include "grains.h"
#include <stdint.h>
uint64_t square(uint8_t index) {
if (index == 0 || index > MAX_SQUARES) {
return 0;
}
return (uint64_t)1 << (index - 1);
}
uint64_t total(void) {
uint64_t result = 1;
for (int i = 1; i <= MAX_SQUARES; i++) {
result += 1 << i;
}
return result;
}