Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix tailrec version of recursion #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

melrief
Copy link

@melrief melrief commented Jul 24, 2017

Tail Recursion should be as faster as a while-loop, sometimes even faster because of internal compiler optimizations. If it's not the case then the developer has done something wrong. In the case of your code, the tail recursion version of fac the "slowness" of the implementation is caused by how you implemented fac, which is different from the while example, and has nothing to do with tail recursion. I've attached to this email a screenshot of the score of my tail recursion implementation (ending with 2) to show that tail recursion is on pair with the while loop. I have only tested Long because I don't have time for the other three tests but I'm fairly confident the result will be similar.

tailrecawesome

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