Sha256: 620354a5310e5e60d12c2a2ce21816285e6c8cff41d9485157cce0d0a563da3b
Contents?: true
Size: 446 Bytes
Versions: 139
Compression:
Stored size: 446 Bytes
Contents
class SumOfMultiples { private numbers: number[] constructor(numbers: number[]) { this.numbers = numbers } to(limit: number): number { const multiples = new Set() this.numbers.forEach((n: number) => { let i = n while (i < limit) { multiples.add(i) i += n } }) return [...multiples].reduce((a, b) => a + b, 0) } } export default (numbers: number[]) => new SumOfMultiples(numbers)
Version data entries
139 entries across 139 versions & 1 rubygems