-
-
Notifications
You must be signed in to change notification settings - Fork 129
Add GCD and LCM utility functions to Python snippets #25
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
✅ Deploy Preview for quicksnip ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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.
GDC is already available as a function of the math package in python, so I think it should this function instead of calculating the result itself.
For the LCM you can use x * y // gcd(x, y)
which uses the gdc to calculate the lcm, it's a lot simpler.
Those a suggestion, feel free to ignore them if they dont fit what you want the snippets to look like
a8ef329
to
4631a91
Compare
GDC is already available as a function of the math package in python, so I think it should this function instead of calculating the result itself. For the LCM you can use
x * y // gcd(x, y)
which uses the gdc to calculate the lcm, it's a lot simpler.Those a suggestion, feel free to ignore them if they dont fit what you want the snippets to look like
You are right, i totally forgot. Instead i made some string manipulation snippets I will show on a new pull request.
Already built-in functions from the math packages
I added 2 code snippets, one for finding the greatest common divisor (GCD) of two numbers using the Euclidean algorithm and a second one for finding the least common multiple (LCM) of two numbers.