efficient solution for GCD question#1035
efficient solution for GCD question#1035aka-0803 wants to merge 1 commit intoTheAlgorithms:masterfrom aka-0803:master
Conversation
->used Euclidean algorithm ->Time Complexity: O(min(a,b)) ->Auxiliary Space: O(min(a,b)) -> more about Euclidean algorithm ->clean code
Panquesito7
left a comment
There was a problem hiding this comment.
For more information, check our contributing guidelines carefully.
If you need any help, let us know here or on our Discord server! 🙂
| #include <bits/stdc++.h> | ||
| using namespace std; |
There was a problem hiding this comment.
These are discouraged. Please use each header/library you need and strictly use std::.
| #include <bits/stdc++.h> | ||
| using namespace std; | ||
|
|
||
| int gcd(int a, int b) |
There was a problem hiding this comment.
Functions should be documented explaining the use of its parameters, a brief description, and what it returns.
| @@ -0,0 +1,44 @@ | |||
| /** | |||
| * @file gcd.cpp | |||
There was a problem hiding this comment.
No need to add the filename. It's best to let Doxygen automatically detect it, otherwise, you'd have to specify the whole directory as well.
| * @file gcd.cpp | |
| * @file |
| * Time Complexity: O(min(a,b)) | ||
| * Auxiliary Space: O(min(a,b)) | ||
| * @author Akash (https://github.com/aka-0803) | ||
| * @copyright Copyright (c) 2022 |
There was a problem hiding this comment.
This is unneeded.
| * @copyright Copyright (c) 2022 |
| * @details | ||
| * Time Complexity: O(min(a,b)) | ||
| * Auxiliary Space: O(min(a,b)) | ||
| * @author Akash (https://github.com/aka-0803) |
There was a problem hiding this comment.
Always use Markdown when specifying the author's name and GitHub link.
| * @author Akash (https://github.com/aka-0803) | |
| * @author [Akash](https://github.com/aka-0803) |
| * @brief | ||
| * The idea is, GCD of two numbers doesn’t change if smaller number is subtracted from a bigger number. | ||
| * More about Euclidean algorithm-> https://www.geeksforgeeks.org/euclidean-algorithms-basic-and-extended/ | ||
| * @details |
There was a problem hiding this comment.
Please add more details about the algorithm itself, how it works, etc.. You can take a bit of information from other sources as long as it's not plagiarism.
|
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! |
->used Euclidean algorithm
->Time Complexity: O(min(a,b))
->Auxiliary Space: O(min(a,b))
-> more about Euclidean algorithm
->clean code
Description of Change
References
Checklist
Notes: