Add pronic number implementation#1023
Conversation
raklaptudirm
left a comment
There was a problem hiding this comment.
Format your code using standard.js. Read the CONTRIBUTING.md before contributing.
Reduced time complexity from O(sqrt(n)) to O(1)
|
The current implementation is very odd: (1) you don't need to check whether numbers are odd if your equation works (2) your equation is unnecessarily convoluted. |
Refactored it, have a look. |
|
Why use if (number === 0) return true
const sqrt = Math.sqrt(number)
return sqrt % 1 !== 0 && Math.ceil(sqrt) * Math.floor(sqrt) === numberPlease extend the tests to check all example numbers listed on https://oeis.org/A002378 - it's easy to mess up some edge cases. Also check that all other numbers in the range aren't false positives. |
Added, have a look. |
Describe your change:
Checklist:
Example:
UserProfile.jsis allowed butuserprofile.js,Userprofile.js,user-Profile.js,userProfile.jsare notFixes: #{$ISSUE_NO}.