Skip to content

Commit

Permalink
feat: 'Return the first M multiples of N'
Browse files Browse the repository at this point in the history
Add 'Return the first M multiples of N' kata
  • Loading branch information
marcobiedermann committed Jul 13, 2020
1 parent a882c30 commit d8c5902
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
9 changes: 9 additions & 0 deletions kata/7 kyu/return-the-first-m-multiples-of-n/index.test.ts
@@ -0,0 +1,9 @@
import multiples from '.';

describe('multiples', () => {
it('should return an array of the first `m` multiples of `n`', () => {
expect.assertions(1);

expect(multiples(3, 5)).toStrictEqual([5, 10, 15]);
});
});
5 changes: 5 additions & 0 deletions kata/7 kyu/return-the-first-m-multiples-of-n/index.ts
@@ -0,0 +1,5 @@
function multiples(m: number, n: number): number[] {
return Array.from({ length: m }, (_, index) => (index + 1) * n);
}

export default multiples;
25 changes: 25 additions & 0 deletions kata/7 kyu/return-the-first-m-multiples-of-n/readme.md
@@ -0,0 +1,25 @@
# [Return the first M multiples of N](https://www.codewars.com/kata/593c9175933500f33400003e)

Implement a function, `multiples(m, n)`, which returns an array of the first `m` multiples of the real number `n`. Assume that `m` is a positive integer.

Ex.

```
multiples(3, 5.0)
```

should return

```
[5.0, 10.0, 15.0]
```

---

## Tags

- Algorithms
- Fundamentals
- Logic
- Mathematics
- Numbers

0 comments on commit d8c5902

Please sign in to comment.