Sha256: fa0ecae98e2cf8f62d010c362683757edae5b18a8bd187814752494369734e85

Contents?: true

Size: 594 Bytes

Versions: 133

Compression:

Stored size: 594 Bytes

Contents

#include "sum_of_multiples.h"
#include <stdbool.h>

unsigned int sum_of_multiples(const unsigned int *multiples,
                              const size_t number_of_multiples,
                              const unsigned int upper_bound)
{
   unsigned int sum = 0;
   if (NULL == multiples)
      return sum;

   for (unsigned int current = 1; current < upper_bound; current++) {
      for (size_t i = 0; i < number_of_multiples; i++) {
         if (0 != multiples[i] && (current % multiples[i]) == 0) {
            sum += current;
            break;
         }
      }
   }

   return sum;
}

Version data entries

133 entries across 133 versions & 1 rubygems

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