https://github.com/richienb/split-integer
Split up an integer into even parts that add to the original integer.
https://github.com/richienb/split-integer
Last synced: 10 months ago
JSON representation
Split up an integer into even parts that add to the original integer.
- Host: GitHub
- URL: https://github.com/richienb/split-integer
- Owner: Richienb
- License: mit
- Created: 2020-10-07T14:35:36.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-10-08T04:36:19.000Z (over 5 years ago)
- Last Synced: 2025-02-22T12:37:16.199Z (11 months ago)
- Language: JavaScript
- Size: 10.7 KB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Funding: .github/FUNDING.yml
- License: license
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# split-integer [](https://travis-ci.com/Richienb/split-integer)
Split up an integer into even parts that add to the original integer.
[](https://npmjs.com/package/split-integer)
## Install
```sh
npm install split-integer
```
## Usage
```js
const splitInteger = require("split-integer")
splitInteger(10, 2)
//=> [5, 5]
splitInteger(10, 3)
//=> [4, 3, 3]
splitInteger(10, 3, { smallestFirst: true })
//=> [3, 3, 4]
```
## API
### splitInteger(number, parts, options?)
#### number
Type: `number`
The number to split.
#### parts
Type: `number`
The amount of parts to split the number into.
#### options
Type: `object`
##### smallestFirst
Type: `boolean`\
Default: `false`
Whether to order the smallest numbers first in the resulting array.