Sitelet https://web.archive.org/web/20260827142942/https://github.com/TheAlgorithms/C-Plus-Plus/pull/1411
Skip to content

feat: Added Modular Exponentiation - #1411

Closed
proRamLOGO wants to merge 4 commits into
TheAlgorithms:masterfrom
proRamLOGO:master
Closed

feat: Added Modular Exponentiation#1411
proRamLOGO wants to merge 4 commits into
TheAlgorithms:masterfrom
proRamLOGO:master

Conversation

@proRamLOGO

@proRamLOGO proRamLOGO commented Oct 29, 2020 •

Copy link
Copy Markdown

Description of Change

Added Modular Exponentiation iterative and recursive.
Added bitwise operations to speed up the processing of program.

Checklist

  • Added description of change
  • Added file name matches File name guidelines
  • Added tests and example, test must pass
  • Added documentation so that the program is self-explanatory and educational - Doxygen guidelines
  • Relevant documentation/comments is changed or added
  • PR title follows semantic commit guidelines
  • Search previous suggestions before making a new one, as yours may be a duplicate.
  • I acknowledge that all my contributions will be made under the project's license.

Notes: Added 2 functions with relevant descriptions and tests.

Added Modular Exponentiation iterative and recursive.
Added bitwise operations to speed up the processing of program.
@proRamLOGO proRamLOGO changed the title Added Modular Exponentiation feat: Added Modular Exponentiation Oct 29, 2020

@Panquesito7 Panquesito7 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this PR about adding Modular Exponentiation, or about improving math/binary_exponent.cpp?

Comment thread math/binary_exponent.cpp

/// Recursive function to calculate exponent modular m (a^b %m) in \f$O(\log(n))\f$ using
/// binary exponentiation.
uint64_t binModExpo(uint64_t a, uint64_t b, uint64_t m) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Function documentation is not up to the Doxygen guidelines.

Comment thread math/binary_exponent.cpp

/// Iterative function to calculate exponent modular m (a^b %m) in \f$O(\log(n))\f$ using
/// binary exponentiation.
uint64_t binModExpo_alt(uint64_t a, uint64_t b, uint64_t m) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same here as above.

Comment thread math/binary_exponent.cpp
return res;
}

/// Main function

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
/// Main function
/**
* @brief Main function
* @returns 0 on exit
*/

Comment thread math/binary_exponent.cpp
std::cout << "Result of a^b Recursive : " << binExpo(a,b) << std::endl;
std::cout << "Result of a^b%m Recursive : " << binModExpo(a,b,m) << std::endl;
std::cout << "Result of a^b Iterative : " << binExpo_alt(a,b) << std::endl;
std::cout << "Result of a^b%m Iterative : " << binModExpo_alt(a,b,m) << std::endl;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
std::cout << "Result of a^b%m Iterative : " << binModExpo_alt(a,b,m) << std::endl;
std::cout << "Result of a^b%m Iterative : " << binModExpo_alt(a,b,m) << std::endl;
return 0;

@Panquesito7 Panquesito7 added automated tests are failing Do not merge until tests pass Improvement improvement in previously written codes requested changes changes have been requested labels Oct 29, 2020
@proRamLOGO

Copy link
Copy Markdown
Author

Is this PR about adding Modular Exponentiation, or about improving math/binary_exponent.cpp?

Adding Modular Exponentiation

@Panquesito7

Copy link
Copy Markdown
Member

I do not see Modular Exponentiation being added.

@stale

stale Bot commented Jul 11, 2021

Copy link
Copy Markdown

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.

@stale stale Bot added the stale Author has not responded to the comments for over 2 weeks label Jul 11, 2021
@stale

stale Bot commented Jul 21, 2021

Copy link
Copy Markdown

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. Thank you for your contributions!

@stale stale Bot closed this Jul 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated tests are failing Do not merge until tests pass Improvement improvement in previously written codes requested changes changes have been requested stale Author has not responded to the comments for over 2 weeks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants