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

Version Path
trackler-2.2.1.180 tracks/typescript/exercises/sum-of-multiples/sum-of-multiples.example.ts
trackler-2.2.1.179 tracks/typescript/exercises/sum-of-multiples/sum-of-multiples.example.ts
trackler-2.2.1.178 tracks/typescript/exercises/sum-of-multiples/sum-of-multiples.example.ts
trackler-2.2.1.177 tracks/typescript/exercises/sum-of-multiples/sum-of-multiples.example.ts
trackler-2.2.1.176 tracks/typescript/exercises/sum-of-multiples/sum-of-multiples.example.ts
trackler-2.2.1.175 tracks/typescript/exercises/sum-of-multiples/sum-of-multiples.example.ts
trackler-2.2.1.174 tracks/typescript/exercises/sum-of-multiples/sum-of-multiples.example.ts
trackler-2.2.1.173 tracks/typescript/exercises/sum-of-multiples/sum-of-multiples.example.ts
trackler-2.2.1.172 tracks/typescript/exercises/sum-of-multiples/sum-of-multiples.example.ts
trackler-2.2.1.171 tracks/typescript/exercises/sum-of-multiples/sum-of-multiples.example.ts
trackler-2.2.1.170 tracks/typescript/exercises/sum-of-multiples/sum-of-multiples.example.ts
trackler-2.2.1.169 tracks/typescript/exercises/sum-of-multiples/sum-of-multiples.example.ts
trackler-2.2.1.167 tracks/typescript/exercises/sum-of-multiples/sum-of-multiples.example.ts
trackler-2.2.1.166 tracks/typescript/exercises/sum-of-multiples/sum-of-multiples.example.ts
trackler-2.2.1.165 tracks/typescript/exercises/sum-of-multiples/sum-of-multiples.example.ts
trackler-2.2.1.164 tracks/typescript/exercises/sum-of-multiples/sum-of-multiples.example.ts
trackler-2.2.1.163 tracks/typescript/exercises/sum-of-multiples/sum-of-multiples.example.ts
trackler-2.2.1.162 tracks/typescript/exercises/sum-of-multiples/sum-of-multiples.example.ts
trackler-2.2.1.161 tracks/typescript/exercises/sum-of-multiples/sum-of-multiples.example.ts
trackler-2.2.1.160 tracks/typescript/exercises/sum-of-multiples/sum-of-multiples.example.ts