2

There is a very nice way to find a modular inverse (that is, such b that ab ≡ 1 (mod m) for given a and m) in :

b = pow(a, -1, m)

pow is built-in in . Is there something like this in ?

Zhiltsoff Igor
  • 1,912
  • 7
  • 24
  • 1
    does this help you? https://stackoverflow.com/questions/53821181/what-can-i-do-on-c-to-do-an-inverse-of-a-number – Coder Jan 10 '21 at 12:29
  • 1
    Does this answer your question? [What can I do on c++ to do an inverse of a number?](https://stackoverflow.com/questions/53821181/what-can-i-do-on-c-to-do-an-inverse-of-a-number) – Coder Jan 10 '21 at 12:29
  • 1
    see also this: [Modular Exponentiation for high numbers in C++](https://stackoverflow.com/questions/2207006/modular-exponentiation-for-high-numbers-in-c) – bolov Jan 10 '21 at 12:30
  • 1
    and to answer your question: no, afaik there is no such function in the standard library (ofc there is `std::pow` but it takes only 2 arguments, doesn't do modulo) – bolov Jan 10 '21 at 12:31
  • 1
    @JohnD, thank you, those posts help me, yet they do not answer my question - I stressed the **built-in** nature in my question. – Zhiltsoff Igor Jan 10 '21 at 12:36
  • 1
    @bolov, well, I guess, your **No** answers my question :). Alas. Yet, thank you. – Zhiltsoff Igor Jan 10 '21 at 12:37
  • 1
    ok ill resolve this then – Coder Jan 10 '21 at 12:59

1 Answers1

1

No there is no built-in function in C++ (to answer your question :) ).

Coder
  • 1,134
  • 1
  • 11
  • 25