From 563e29acaef009b433f772dafb02443a9b1a1883 Mon Sep 17 00:00:00 2001 From: Mann Mehta <44433995+mann2108@users.noreply.github.com> Date: Sat, 9 May 2020 17:31:48 +0530 Subject: [PATCH] Resolve errors in math/mod_inverse_by_fermat_theorem.cpp --- math/mod_inverse_by_fermat_theorem.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/math/mod_inverse_by_fermat_theorem.cpp b/math/mod_inverse_by_fermat_theorem.cpp index 30702b8cd..e4b0fa095 100644 --- a/math/mod_inverse_by_fermat_theorem.cpp +++ b/math/mod_inverse_by_fermat_theorem.cpp @@ -53,7 +53,7 @@ bool isPrime(int64_t m) { if (m <= 1) { return false; } else { - for(int i=2; i*i <= m; i++) { + for (int i=2; i*i <= m; i++) { if (m%i == 0) { return false; } @@ -65,13 +65,15 @@ bool isPrime(int64_t m) { int main() { int64_t a, m; // Take input of a and m. - std::cout << "Computing ((a^(-1))%(m)) using Fermat's Little Theorem" << std::endl; - std::cout << "Give input 'a' and 'm' space separated (m must be a prime number) : "; + std::cout << "Computing ((a^(-1))%(m)) using Fermat's Little Theorem"; + std:: cout << std::endl << std::endl; + std::cout << "Give input 'a' and 'm' space separated : "; std::cin >> a >> m; if (isPrime(m)) { std::cout << "The modular inverse of a with mod m is (a^(m-2)) : "; std::cout << binExpo(a, m-2, m) << std::endl; } else { - std::cout << "m must be a prime number to apply Fermat's Little Theorem." << std::endl; + std::cout << "m must be a prime number to apply Fermat's Little Theorem."; + std::cout << std::endl; } }