Skip to content

Conversation

piyushkumar0707
Copy link
Contributor

🚀 Overview

This PR implements the Extended Euclidean Algorithm - an advanced number theory algorithm that finds GCD and Bézout coefficients, with applications in cryptography and modular arithmetic.

✨ Features

  • Recursive & iterative versions - Two implementation approaches
  • Bézout coefficient calculation - Find x, y such that ax + by = gcd(a,b)
  • Modular multiplicative inverse - Essential for cryptography
  • Diophantine equation solver - Solve ax + by = c
  • Range-based solutions - Find all solutions in given bounds
  • Practical applications - Real-world problem examples

🎯 Why This Matters

Extended Euclidean Algorithm is crucial for:

  • RSA Cryptography - Computing modular inverses for key generation
  • Modular arithmetic - Solving congruences and inverse calculations
  • Number theory - Fundamental tool for mathematical proofs
  • Competitive programming - Advanced mathematical contests
  • Computer algebra - Symbolic computation systems
  • Error correction codes - Coding theory applications

📚 Implementation Details

  • Time Complexity: O(log(min(a, b))) - same as regular GCD
  • Space Complexity: O(log(min(a, b))) recursive, O(1) iterative
  • Algorithm: Extended version of Euclidean GCD algorithm
  • Output: GCD plus coefficients satisfying Bézout's identity

🔧 Advanced Functions

  • extended_gcd_recursive() - Classic recursive approach
  • extended_gcd_iterative() - Memory-efficient iterative version
  • modular_inverse() - Find multiplicative inverse mod m
  • solve_diophantine() - Solve linear Diophantine equations
  • find_diophantine_solutions_in_range() - Bounded solution finder

🧮 Mathematical Applications

Bézout's Identity: For any integers a, b, there exist integers x, y such that:

- Implement both recursive and iterative versions
- Include modular multiplicative inverse calculation
- Add linear Diophantine equation solver
- Comprehensive examples with practical applications
- Update DIRECTORY.md to include the new algorithm
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements the Extended Euclidean Algorithm in R, which computes the GCD of two integers along with Bézout coefficients that satisfy the identity ax + by = gcd(a,b). The implementation provides both recursive and iterative approaches with practical applications in cryptography and number theory.

  • Implements recursive and iterative Extended Euclidean Algorithm functions
  • Adds modular multiplicative inverse calculation for cryptographic applications
  • Includes Diophantine equation solver with range-based solution finding
  • Provides comprehensive examples and test cases demonstrating real-world applications

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
mathematics/extended_euclidean_algorithm.r Complete implementation of Extended Euclidean Algorithm with multiple variants and practical applications
DIRECTORY.md Added entry for the new Extended Euclidean Algorithm file in the mathematics section

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Member

@siriak siriak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@siriak siriak merged commit 6e76d34 into TheAlgorithms:master Oct 4, 2025
2 checks passed
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.

2 participants