A summary of number theory algorithms

Source: Internet
Author: User
Tags gcd

Ma Xiao theorem of sum-up fee for number theory algorithm

\ (A^{p-1} \equiv 1 \pmod{p}\space ((a,p) =1,isprime (p)) \)

    • Proof: Link
      The general form is given here: Consider the remainder of any positive integer \ (A\mod p\space ((a,p) =1) \) , with \ (1,2,3,\ldots, p-1\).
      Then we take any positive integer \ (a ' ((a ', p) =1) \), the remaining system is multiplied by \ (a ' \) and then \ ( \mod p\) , the remaining system or \ (1,2,\ldots,p-1\) one of the permutations.
      Multiply these numbers to get:\ (A ' ^{p-1}\times (p-1)! \equiv (p-1)! \mod p\), on both sides with the exception \ ((p-1)!\) get:\ (a ' ^{p-1}\times 1 \ EQUIV 1 \mod p\), replace \ (a ' \) with \ (a\) .
      The inverse element is \ (A^{p-2}\times a \equiv 1 \pmod{p}\).
      Note that all the derivation is under the conditions of the above equation.
Euler's theorem

\ (A^{\phi (n)}\equiv 1 \pmod{n} ((a,n) =1) \)

    • It is easy to find that the front Fermat theorem is the son theorem of Euler's theorem.
      The main reason is to add why \ (a\times x_i \mod N ((a,n) =1,x_i\leq n) \) has \ (\phi (n) \) results.
      Assuming \ (m_i=a\times x_i\), then the assumption exists \ (m_i\equiv m_j \pmod{n} (i\not =j) \), then there is:\ (A (x_j-x_i) = kn\) , but because \ ((a,n) =1\),\ (x_j-x_i<n\), it is impossible to have a solution anyway. The remaining proof is the same as above.
Expanding Euler's theorem

\ (A^b\equiv \begin{cases} a^{b\%\phi (P)}~~~~~~~~~~~gcd (a,p) =1\\ a^b~~~~~~~~~~~~~~~~~~gcd (a,p) \neq1,b<\phi (p) \ \ A^{b\%\phi (P) +\phi (p)}~~~~gcd (a,p) \neq1,b\geq\phi (p) \end{cases}~~~~~~~ (mod~p) \)

Proof: Link

Bsgs

Given \ (a,b,p\), the smallest nonnegative integer \ (x\) order \ ( x\) satisfies \ (a^x \equiv b \pmod{p}\).

First there is the Fermat theorem:\ (A^{k\mod (p-1)}\equiv a^k \pmod{p}\), so say \ (x< p-1\).
Then we make \ (M=\lceil \sqrt{p} \rceil\) ,\ (x=i\times m-j\), then there are:\[a^{i\times m-j}\equiv b \pmod{p}\]
\[a^{i\times m}\equiv b \times a^j\pmod{p}\]
So the violence in \ (0\to m\) enumeration \ (j\), deposit the hash table, and then in \ (1\to m\) enumeration I query.

A summary of number theory algorithms

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.