Zoj -- 1489--2 ^ x mod n = 1

Source: Internet
Author: User

This question requires the smallest positive integer x, N> 0 that satisfies 2 ^ x limit 1 (mod N.

First consider the Euler's Theorem 2 ^ Eular (n) limit 1 (mod N), which requires n> 1. So when n = 1, in fact, all K numbers have k limit 0 (mod N), which is a special decision.

In the Euler's theorem, Eular (n) must be cyclic, but not necessarily the smallest cyclic section: When eg: n = 7:

2 ^ 0 mod 7 = 1;

2 ^ 1 mod 7 = 2;

2 ^ 2 mod 7 = 4;

2 ^ 3 mod 7 = 1;

2 ^ 4 mod 7 = 2;

The shortest cycle is 3, which is a factor of the Euler's function Eular (7) = 6.

There are two methods for finding the shortest cycle: 1. brute-force enumeration, with a maximum of Eular (n). The complexity is O (n. 2. enumerate Eular (n) factors from small to large, and then quickly determine the power.

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.