Skip to content

Conversation

@stevencl
Copy link
Owner

It looked like it would be possible to crash factorial by passing in a negative number. So I tried to fix it.

var result = 1;
for(i = 1; i <= n; i++) {
result = result * i;
if (n > 0) {
Copy link
Owner Author

@stevencl stevencl Jan 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be n >= 0? #Resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant