Table A139366 for order r(N,n): least r with n^r congruent 1 (mod N) for given N,n with gcd(N,n)=1 and 0 otherwise. The actual table is only for 1 <= n <= N. It is filled with 0's for n>N to obtain a quadratic scheme. N\n 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 4 1 0 2 0 0 0 0 0 0 0 0 0 0 0 0 5 1 4 4 2 0 0 0 0 0 0 0 0 0 0 0 6 1 0 0 0 2 0 0 0 0 0 0 0 0 0 0 7 1 3 6 3 6 2 0 0 0 0 0 0 0 0 0 8 1 0 2 0 2 0 2 0 0 0 0 0 0 0 0 9 1 6 0 3 6 0 3 2 0 0 0 0 0 0 0 10 1 0 4 0 0 0 4 0 2 0 0 0 0 0 0 11 1 10 5 5 5 10 10 10 5 2 0 0 0 0 0 12 1 0 0 0 2 0 2 0 0 0 2 0 0 0 0 13 1 12 3 6 4 12 12 4 3 6 12 2 0 0 0 14 1 0 6 0 6 0 0 0 3 0 3 0 2 0 0 15 1 4 0 2 0 0 4 4 0 0 2 0 4 2 0 . . . The row N shows, for gcd(N,n)=1 the smallest positive integer power r with n^r equivalent 1 (mod N). If gcd(N,n) is not equal to 1 there is no such power r and one puts 0 (trivial power r). Because for gcd(N,n)=1 one always has n^phi(N) equivalent 1 (mod N) with Euler's totient function A000010(N), r=r(N,n) <= phi(N). The number of 0's in row N for 1<= n <= N is phi(N), and the 0's are at the 1<= n<= N positions which have divisors of N not equal to 1. Row sums give: A036391(N), N>=2. [0, 1, 3, 3, 11, 3, 21, 7, 21, 11, 63, 7, 77, 21, 23, 23, 171, 21, 183, 23, 49, 63, 333, 15, 231, 77, 183, 49, 473, 23, 441, 87, 147, 171, 161, 49, 671, 183, 161, 47,...]. Example for the period r: N=5, n=7, gcd(5,7)=1: 7^1 congruent (congr.) 2 (mod 5), 7^2 congr. 4 (mod 5), 7^3 congr. 3 (mod 5), 7^4 congr. 1 (mod 5),, hence r(5,7)=4, and for other powers one hase the periodic sequence of period r=4: [2,4,3,1,2,4,3,1,2,4,3,1,...]. If gcd(N,n) is not 1, e.g. N=4, n=2, with gcd(4,2)=2, there is no such r>=1: 2^1 congr. 2 (mod4), 2^2 congr. 0 (mod 4), 2^3 congr. 0 (mod 4), etc. In this case a 0 appears in the table for N>=2. For N=1=n: gcd(1,1)=1 but 1^r congr. 0 (mod 1), hence no such r exists also for N=1. ####################################### e.o.f. ###############################################