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

Added Implementation of GCD of two numbers using Euclidean Algorithm #31

Merged
merged 7 commits into from
Dec 16, 2024

Conversation

Subhoshri
Copy link
Contributor

Description

  • Created a function GCD to calculate the Greatest Common Divisor of two numbers 'a' and 'b' using Euclidean Algorithm.
  • It handles edge cases of (0,1), (1,0) and (0,0) well.

Tasks Completed

  • Added the files gcd_euclidean_algorithm.py, gcd_euclidean_algorithm.java and gcd_euclidean_algorithm.cpp in the corresponding directory
  • My code aligns with the specified structure.
  • Updated RoadMap.md

@imsuraj675
Copy link
Owner

Make these modifications:

  • Your code's logic is inconsistent. In Cpp and java, gcd(-2, -4) will give 2, but in python it will return -2. GCD means the largest number which divides both the numbers, so answer of gcd(-2, -4) should be equal to 2.
  • Gcd(0,0) = 0. Don't return, as -1

@Subhoshri
Copy link
Contributor Author

I have made the required changes.

@imsuraj675 imsuraj675 merged commit 754e39f into imsuraj675:main Dec 16, 2024
@imsuraj675
Copy link
Owner

Good work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants