Skip to content

Instantly share code, notes, and snippets.

@QaisPalekar
Last active January 23, 2020 06:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save QaisPalekar/50a335a89db82d7582710544334f6d8d to your computer and use it in GitHub Desktop.
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
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