Skip to content

Conversation

@nlcurry
Copy link

@nlcurry nlcurry commented May 3, 2016

Didn't do optional

def fact(n)
return 1 if n <= 1
n*fact(n-1)
end
Copy link

Choose a reason for hiding this comment

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

I like your choice of "n <= 1" instead of "n==1" here - just in case someone calls it with zero or a negative number, your code won't recurse forever. Good solution.

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.

2 participants