the-honk/euler/src/1 - Multiples of 3 or 5.ts
2021-10-29 01:00:43 +01:00

12 lines
322 B
TypeScript

import { calcSum } from './utils';
const below = 1000;
const multiplesOf = [3, 5];
const toAdd: Set<number> = new Set();
// Find all of the multiples of 3 and 5 below 1000
for (let i = 1; i < below; i++) {
multiplesOf.forEach(num => (i % num == 0 ? toAdd.add(i) : null));
}
console.log(calcSum(Array.from(toAdd)));