Just list some of the mathematical theorems that have been used in the problem, and make a partial arrangement.
1. The number of digits of N:
LOG10 (N)
2, N is prime number:
A^m = a^ (m% (n-1)) (mod n)
3, Euler function:
The number that is smaller than the number of equals n, and n coprime number.
Euler function Expression formula:Euler (x) =x (1-1/P1) (1-1/P2) (1-1/P3) (1-1/P4) ... (1-1/PN),
Where P1,P2......PN is the total factor of x, X is an integer that is not 0.
Euler (1) =1 (the number of unique and 1 coprime is 1 itself).
Supplementary nature:
(1) for Prime p,φ (P) = p-1. Note φ (1) = 1.
(2) for coprime positive integers a and N, there is aφ (n) ≡1 mod n. (Euler's theorem)
(3) If M,n coprime, φ (MN) =φ (m) φ (n).
(4) If n is the K-power of prime number p, φ (n) =p^k-p^ (k-1) = (p-1) p^ (k-1), because the other numbers are the same as n coprime except multiples of p.
(5) When n is odd, φ (2n) =φ (n)
(6) A mass factor of n is set,
if (A | (n/a)) Then there are φ (N) =φ (/N) * A;
Otherwise : φ (n) =φ(/N)* (A-1).
(7) The sum of all the mass factors of a number is Euler (n) *n/2.
4, Cattleya number
The h (0) =1,h (1) =1,catalan number satisfies:
h (n) = h (0) *h (n-1) +h (1) *h (n-2) + ... + h (n-1) H (0) (n>=2)h (N) =h (n-1) * (4*n-2)/(n+1);h (N) =c (2n,n)/(n+1) (n=0,1,2,...)
h (N) =c (2n,n)-C (2n,n-1) (n=0,1,2,...)
Application:parentheses,the stack order,Triangular division of convex polygons,A given node consists of two fork trees
Extensions:for 2 binary in n bits, there are M 0 and the remaining 1 Catalan are: C (n,m)-C (n,m-1).
Essay on number theory (to be added)