Last active
January 23, 2020 06:24
-
-
Save QaisPalekar/50a335a89db82d7582710544334f6d8d to your computer and use it in GitHub Desktop.
Given a number, return true if the input is a factorial of any natural number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isFactorial(num) { | |
let remainder = num; | |
let factorial = 2; | |
while(remainder >= factorial) { | |
remainder = remainder/factorial; | |
factorial++; | |
} | |
return remainder===1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment