Sha256: 7a237d1c6c6ebcdd0c7df5562d92367d8902aba85058b795736e481a28e337aa

Contents?: true

Size: 357 Bytes

Versions: 315

Compression:

Stored size: 357 Bytes

Contents

#include "grains.h"

#define NUMBER_OF_SQUARES   (64)

uint64_t square(uint8_t index)
{
   if ((!index) || (index > NUMBER_OF_SQUARES)) {
      return 0;
   }

   return (uint64_t) 1 << (index - 1);
}

uint64_t total(void)
{
   uint64_t result = 0;

   for (uint8_t i = 1; i <= NUMBER_OF_SQUARES; i++) {
      result += square(i);
   }

   return result;
}

Version data entries

315 entries across 315 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.179 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.178 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.177 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.176 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.175 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.174 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.173 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.172 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.171 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.170 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.169 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.167 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.166 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.165 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.164 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.163 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.162 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.161 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.160 tracks/c/exercises/grains/src/example.c