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.159 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.158 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.157 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.156 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.155 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.154 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.153 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.152 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.151 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.150 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.149 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.148 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.147 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.146 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.145 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.144 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.143 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.142 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.141 tracks/c/exercises/grains/src/example.c
trackler-2.2.1.140 tracks/c/exercises/grains/src/example.c