Skip to content

Split up an integer into even parts that add to the original integer.

License

Notifications You must be signed in to change notification settings

Richienb/split-integer

split-integer Travis CI Build Status

Split up an integer into even parts that add to the original integer.

NPM Badge

Install

npm install split-integer

Usage

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.

About

Split up an integer into even parts that add to the original integer.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published