Sha256: ad2d0cb8b76686c155b5090a095f4000a94152704db50d7fe4f14dd730735602

Contents?: true

Size: 529 Bytes

Versions: 247

Compression:

Stored size: 529 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;

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

   return sum;
}

Version data entries

247 entries across 247 versions & 1 rubygems

Version Path
trackler-2.2.1.45 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.44 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.43 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.42 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.41 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.40 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.39 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.38 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.37 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.36 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.35 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.34 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.33 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.32 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.31 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.30 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.29 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.28 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.27 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.26 tracks/c/exercises/sum-of-multiples/src/example.c