Skip to content

Instantly share code, notes, and snippets.

View kaizer1v's full-sized avatar
👷‍♀️
One day at a time.

Vivek S kaizer1v

👷‍♀️
One day at a time.
View GitHub Profile
@kaizer1v
kaizer1v / factors.js
Last active May 22, 2019 03:01
Produces all the factors of a given integer.
/* produces the factors of a given number */
function _factors(n) {
var factors = [1, n];
for(var i = 2; i <= Math.floor(n/i); i++) {
if(n % i === 0)
if(i === n/i) {
factors.push(i);
}
else
factors.push(i, n/i);