exercism/zig/sum-of-multiples
2024-07-28 17:45:02 -04:00
..
.exercism add zig solutions 2024-07-28 17:45:02 -04:00
HELP.md add zig solutions 2024-07-28 17:45:02 -04:00
README.md add zig solutions 2024-07-28 17:45:02 -04:00
sum_of_multiples.zig add zig solutions 2024-07-28 17:45:02 -04:00
test_sum_of_multiples.zig add zig solutions 2024-07-28 17:45:02 -04:00

Sum of Multiples

Welcome to Sum of Multiples on Exercism's Zig Track. If you need help running the tests or submitting your code, check out HELP.md.

Instructions

Given a list of factors and a limit, add up all the unique multiples of the factors that are less than the limit. All inputs will be greater than or equal to zero.

Example

Suppose the limit is 20 and the list of factors is [3, 5]. We need to find the sum of all unique multiples of 3 and 5 that are less than 20.

Multiples of 3 less than 20: 3, 6, 9, 12, 15, 18 Multiples of 5 less than 20: 5, 10, 15

The unique multiples are: 3, 5, 6, 9, 10, 12, 15, 18

The sum of the unique multiples is: 3 + 5 + 6 + 9 + 10 + 12 + 15 + 18 = 78

So, the answer is 78.

Source

Created by

  • @ee7

Based on

A variation on Problem 1 at Project Euler - https://projecteuler.net/problem=1