Add examples

This commit is contained in:
Rohit Tanwar
2018-01-03 15:51:10 +05:30
committed by GitHub
parent f681af2c16
commit 07809ddc90

View File

@ -32,3 +32,14 @@ const factors = (int,prime = false,powers = false) => {
array = prime ? array.filter(el => isPrime(el)) : array;
return powers ? array.map(x => [x,howManyTimes(int,x)]) : array
};
```
```js
factors(12); //[2,3,4,6,12]
factors(12,true); //[2,3]
factors(12,true,true); //[[2,2], [3,1]]
factors(12,false,true); //[[2,2], [3,1], [4,1], [6,1], [12,1]]
factors(-12); //[2, -2, 3, -3, 4, -4, 6, -6, 12, -12]
factors(12,true); //[2,3]
factors(12,true,true); //[[2,2], [3,1]]
factors(12,false,true); //[[2,2], [-2,2], [3,1], [-3,1], [4,1], [-4,1], [6,1], [-6,1], [12,1], [-12,1]]
```