-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
feat: Added recursive factorial function #736
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Good code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please enable GitHub Actions in your repository of this fork in this link: https://github.com/nicola-masarone/C/actions
Co-authored-by: David Leal <[email protected]>
Co-authored-by: David Leal <[email protected]>
Co-authored-by: David Leal <[email protected]>
118f61e
to
6d5476a
Compare
6d5476a
to
ef595fa
Compare
Thanks for all your suggestions. |
Header file explanation and wikipedia link added
Co-authored-by: David Leal <[email protected]>
Co-authored-by: David Leal <[email protected]>
Co-authored-by: David Leal <[email protected]>
Co-authored-by: David Leal <[email protected]>
ecedb0f
to
5bfe7c1
Compare
Co-authored-by: David Leal <[email protected]>
* @param val input value to calculate the factorial of | ||
* @returns factorial of the input value | ||
*/ | ||
long long factorial_recursive(int val) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
long long factorial_recursive(int val) | |
long long factorial_recursive(const int& val) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't understand this suggested change. Is there any real need to use const int& instead of just int ?
I supposed this code should be useful for beginners too and I think it's much more readable in this way.
I would prefer to leave it just as it is.
Thanks again for your suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This parameter (val
) is not being modified, it is just being used.
It's better and faster to make it a const
and pass it by reference using &
.
If the value is being modified, we shall not use const
, otherwise it'll throw an error.
Reference.
This pull request has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Please ping one of the maintainers once you commit the changes requested or make improvements on the code. If this is not the case and you need some help, feel free to ask for help in our Gitter channel or our Discord server. Thank you for your contributions! |
Description of Change
References
Checklist
Notes:
Recursive factorial function