js-mentorship-razvan / javascript

Javascript study notes
GNU General Public License v3.0
22 stars 2 forks source link

Count the divisors of a number #455

Closed RazvanBugoi closed 4 years ago

RazvanBugoi commented 4 years ago

https://www.codewars.com/kata/542c0f198e077084c0000c2e/train/javascript

RazvanBugoi commented 4 years ago
function getDivisorsCnt(n){
    let output = 0; 
    for (let i=1; i<=n; i++) {
      if (n % i == 0) {
        output += 1; 
}
}
  return output;
}
lilzem commented 1 year ago

it's obvious, but O(n) speed is too slow