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.139 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.138 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.137 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.136 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.135 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.134 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.133 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.132 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.131 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.130 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.129 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.128 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.127 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.126 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.125 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.124 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.123 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.122 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.121 tracks/c/exercises/sum-of-multiples/src/example.c
trackler-2.2.1.120 tracks/c/exercises/sum-of-multiples/src/example.c