Keywords

1 Introduction

For an integer \(m\ge 2\), let \(\mathbf {Z}/(m)\) denote the integer residue ring modulo m. The set \(\{0,1,\ldots ,m-1\}\) is always chosen as the complete set of representatives for the elements of the ring \(\mathbf {Z}/(m)\). Thus a sequence \(\underline{a}\) over \(\mathbf {Z}/(m)\) is usually seen as an integer sequence over \(\{0,1,\ldots ,m-1\}\). Moreover, for an integer a and a positive integer \(b\ge 2\), let us denote the least nonnegative residue of a modulo b by \(\left[ a\right] _{\text {mod}\, b}\), and similarly, for a sequence \(\underline{a}=(a(t))_{t\ge 0}\) over \(\mathbf {Z}/(m)\), denote \(\left[ \underline{a}\right] _{\text {mod}\, b}=\left( \left[ a(t)\right] _{\text {mod}\, b}\right) _{t\ge 0}\).

Let p be a prime number and e a positive integer. During the past two decades, the maximal period linear recurring sequences over \(\mathbf {Z} /(p^{e})\), called primitive sequences over \(\mathbf {Z}/(p^{e})\), have been paid much attention. An enormous amount of effort is directed toward the study of finding useful mappings to derive good pseudorandom sequences from primitive sequences over \(\mathbf {Z}/(p^{e})\), which are called compression mappings in literature, and proving that they are injective. Generally there are two kinds of compression mappings: one is based on e-variable functions over \(\mathbf {Z}/(p)\) [10, 15,16,17, 20, 21]; the other is based on the modular arithmetic [13, 22]. Besides, the pseudorandom properties of these compression sequences are also extensively studied, such as periodicity [7, 13], linear complexity [3, 6, 15] and distribution properties [2, 8, 12, 23].

Recently research interests on primitive sequences over \(\mathbf {Z}/(p^{e})\) are further extended to primitive sequences over \(\mathbf {Z}/(M)\) [4, 9, 24,25,26,27], where M is a square-free odd integer. One of important reasons for this is that the period of a primitive sequence \( \underline{a}\) of order n over \(\mathbf {Z}/(p^{e})\) is undesirable if \( e\ge 2\). Recall that the period \(per(\underline{a})\) of a primitive sequence \(\underline{a}\) of order n over \(\mathbf {Z}/(p^{e})\) is equal to \( p^{e-1}\cdot \left( p^{n}-1\right) \approx p^{e+n-1}\) [18]. It can be seen that for a fixed prime power \(p^{e}\) with \(e\ge 2\), the period \(per( \underline{a})\) increases slowly and far less than \(p^{e\cdot n}\) as n increases. Therefore, to meet the requirement of long period in practical applications, n should be chosen large enough, which will be high resource consumption in hardware and software implementation. For example, to generate a sequence with period not less than \(2^{64}\) over \(\mathbf {Z} /(2^{8})\), \(\mathbf {Z}/(2^{16})\) and \(\mathbf {Z}/(2^{32})\), the number of bit-registers required must be larger than 456, 784 and 1056, respectively. However for many choices of M, primitive sequences over \( \mathbf {Z}/(M)\) have no such periodic weakness. For cryptographic applications, the moduli of the form \(2^{e}-1\) have attracted much attention since the operation “\(\text {mod}\, 2^{e}-1\)” can be efficiently implemented both in hardware and software, and this offers new possibilities for advancement in the solution of applying linear recurring sequences over integer residue rings. For instance, primitive sequences over \(\mathbf {Z}/(2^{31}-1)\) are used to design the ZUC algorithm, a stream cipher that is the core of the standardised 3GPP confidentiality algorithm 128-EEA3 and the 3GPP integrity algorithm 128-EIA3, see [28].

By applying the operation \(\text {mod}\, 2\) to primitive sequences over \(\mathbf {Z} /(M)\), one can easily obtain a class of binary sequences, called modulo 2 reductions of primitive sequences over \(\mathbf {Z}/(M)\). It is thought that the operation \(\text {mod}\, 2\) destroys the original linear recurrence relation of primitive sequences over \(\mathbf {Z}/(M)\) and the obtained binary sequences should have many desirable cryptographic properties if the modulus M and the order n are carefully chosen. One of the most interesting properties is the so-called “modulo 2 distinctness”. Some progress has been made on the modulo 2 distinctness, see, for example, [9, 26]. From the viewpoint of cryptographic applications, it is naturally interested in the pseudorandom properties of modulo 2 reductions of primitive sequences over \(\mathbf {Z}/(M)\). However, so far few result was obtained. In [25], to study the modulo 2 distinctness of primitive sequences over \(\mathbf {Z}/(M)\), two distribution properties of primitive sequences over \(\mathbf {Z}/(M)\) are investigated. One is to determine whether there is an integer \(t\ge 0\) such that \(a(t)=s\) for a given element \(s\in \mathbf {Z}/(M)\) and a given primitive sequence \( \underline{a}\) of order n over \(\mathbf {Z}/(M)\). The other is to determine whether there is an integer \(t\ge 0\) such that a(t) is an even number for a given primitive sequence \(\underline{a}\) of order 1 over \(\mathbf {Z}/(M)\). In [9], Hu and Wang studied whether there is an integer \(t\ge 0\) such that \(a(t)=a\) and \(b(t)=b\), for two given elements \(a,b\in \mathbf {Z} /(M)\) and two given primitive sequences \(\underline{a},\underline{b}\) generated by a same primitive polynomial over \(\mathbf {Z}/(M)\).

In this paper, we study the distribution properties of the binary sequence \( \left[ \underline{a}\right] _{\text {mod}\, 2}\), where \(\underline{a}\) is a primitive sequence of order n over \(\mathbf {Z}/(M)\) with period T. With the estimate of exponential sums over \(\mathbf {Z}/(M)\), the proportion \(f_{s} \) of occurrences of s within a segment of \(\left[ \underline{a}\right] _{\text {mod}\, 2}\) of length \(\mu T\) is estimated, where \(s\in \left\{ 0,1\right\} \) and \(0<\mu \le 1\). Based on this estimate, it is further shown that for given M and \(\mu \), \(f_{s}\) tends to \(\left( M+1-2s\right) /2M\) as \(n\rightarrow \infty \). Generally speaking, if n is not too small (for example, \(n\ge 3\) for \(M=2^{32}-1\)), then the value of \( f_{s}\) is very close to that of \(\left( M+1-2s\right) /2M\). This implies that there always exists a small imbalance (about 1/M) between 0 and 1 in \(\left[ \underline{a}\right] _{\text {mod}\, 2}\). In order to provide a good resistance against the distinguishing attacks, such imbalance should be taken into full consideration in the design of stream ciphers based on \( \left[ \underline{a}\right] _{\text {mod}\, 2}\). Fortunately, by introducing a moderate amount of exclusive or operations, the imbalance of 0, 1 will be reduced to a small enough extent.

The rest of this paper is organized as follows. Section 2 presents some necessary preliminaries. Section 3 gives the main results of this paper. Finally, conclusions are drawn in Sect. 4.

2 Preliminaries

2.1 Primitive Polynomials and Primitive Sequences over Integer Residue Rings

Let m be an integer greater than 1. If a sequence \(\underline{a}=(a(t))_{t\ge 0}\) over \(\mathbf {Z}/(m)\) satisfies

$$\begin{aligned} a(t)=\left[ c_{n-1}a(t-1)+\cdots +c_{1}a(t-n+1)+c_{0}a(t-n)\right] _{\text {mod}\, m} \end{aligned}$$
(1)

for all integers \(t\ge n\), where n is a positive integer and \( c_{0},c_{1},\ldots ,c_{n-1}\in \mathbf {Z}/(m)\) are constant coefficients, then \(\underline{a}\) is called a linear recurring sequence of order n over \(\mathbf {Z}/(m)\) generated by \(f(x)=x^{n}-c_{n-1}x^{n-1}-\cdots -c_{0}\) (or \(\underline{a}\) is a sequence of order n over \(\mathbf {Z}/(m)\) in short). For convenience, the set of sequences generated by f(x) over \( \mathbf {Z}/(m)\) is generally denoted by \(G\left( f\left( x\right) ,m\right) \). Particular interests for cryptography are the maximal period linear recurring sequences also called primitive sequences over \(\mathbf {Z}/(m)\), which are generated by primitive polynomials over \(\mathbf {Z}/(m)\). Next we introduce the definitions of primitive polynomials and primitive sequences over \(\mathbf {Z}/(m)\).

Let \(f\left( x\right) \) be a monic polynomial of degree n over \(\mathbf {Z} /(m)\). If \(\gcd (f\left( 0\right) ,m)=1\), then there exists a positive integer T such that \(x^{T}-1\) is divisible by f(x) in \(\mathbf {Z}/(m)[x]\). The minimum of such T is called the period of \(f\left( x\right) \) over \( \mathbf {Z}/(m)\) and denoted by \(per\left( f\left( x\right) ,m\right) \). For the case that m is a prime power, say \(m=p^{e}\), it is known that \( per\left( f\left( x\right) ,p^{e}\right) \le p^{e-1}(p^{n}-1)\), see [18]. If \(per\left( f\left( x\right) ,p^{e}\right) =p^{e-1}(p^{n}-1)\), then \(f\left( x\right) \) is called a primitive polynomial of degree n over \(\mathbf {Z}/(p^{e})\). A sequence \(\underline{a}\) over \(\mathbf {Z} /(p^{e})\) is called a primitive sequence of order n if \(\underline{a}\) is generated by a primitive polynomial of degree n over \(\mathbf {Z}/(p^{e})\) and \(\left[ \underline{a}\right] _{\text {mod}\, p}\) is not an all-zero sequence. A primitive sequence \(\underline{a}\) of order n over \(\mathbf {Z}/(p^{e})\) is (strictly) periodic and the period \(per(\underline{a})\) is equal to \(p^{e-1}(p^{n}-1)\), see [18]. For the case of a general integer m, assume \(m=p_{1}^{e_{1}}p_{2}^{e_{2}}\cdots p_{r}^{e_{r}}\) is the canonical factorization of m. A monic polynomial \(f\left( x\right) \) of degree n over \(\mathbf {Z}/(m)\) is called a primitive polynomial if for every \(k\in \left\{ 1,2,\ldots ,r\right\} \), \(f\left( x\right) \) is a primitive polynomial of degree n over \(\mathbf {Z}/(p_{k}^{e_{k}})\). A sequence \(\underline{a}\) over \(\mathbf {Z}/(m)\) is called a primitive sequence of order n if \(\underline{a}\) is generated by a primitive polynomial of degree n over \(\mathbf {Z}/(m)\) and \(\left[ \underline{a}\right] _{\text {mod}\, p_{k}}\) is not an all-zero sequence for every \(k\in \left\{ 1,2,\ldots ,r\right\} \), that is, \(\left[ \underline{a}\right] _{\text {mod}\, p_{k}^{e_{k}}}\) is a primitive sequence of order n over \(\mathbf {Z}/(p_{k}^{e_{k}})\). It can be seen that the period of a primitive polynomial of degree n over \(\mathbf {Z}/(m)\) and that of a primitive sequence of order n over \(\mathbf {Z}/(m)\) are both equal to

$$ \text {lcm}\left( p_{1}^{e_{1}-1}\left( p_{1}^{n}-1\right) ,p_{2}^{e_{2}-1}\left( p_{2}^{n}-1\right) ,\ldots ,p_{r}^{e_{r}-1}\left( p_{r}^{n}-1\right) \right) \text {.} $$

For convenience, the set of primitive sequences generated by a primitive polynomial f(x) over \(\mathbf {Z}/(m)\) is generally denoted by \(G^{\prime }(f(x),m)\).

2.2 Exponential Sums over Integer Residue Rings

Let m be a positive integer greater than 1, and let \(e_{m}\left( \cdot \right) \) be the canonical additive character over \(\mathbf {Z}/(m)\) given by \(e_{m}(a)=e^{2\pi ia/m}\), where a is an integer. For an integer c, it is well-known that

$$ \sum _{a=0}^{m-1}e_{m}\left( ca\right) =\left\{ \begin{array}{l} m,\text { if }m\mid c\text {;} \\ 0,\text { otherwise.} \end{array} \right. $$

The following Lemma 1 is cited from [5, Theorem 1].

Lemma 1

([5, Theorem 1]) Let \(D\ge 1\), \(m\ge 2\) and \(g=\gcd (m,D)\). Then we have

$$\begin{aligned} \sum _{a=1}^{m-1}\left| \frac{\sin \pi aD/m}{\sin \pi a/m}\right| < \frac{4}{\pi ^{2}}m\ln m+0.38m+0.608+0.116\frac{g^{2}}{m}, \end{aligned}$$

where \(\ln (m)\) is the natural logarithm of m.

The following Lemma 2 is an improvement of a well-known result of Korobov [14, Theorem 13].

Lemma 2

Let \(\underline{a}\) be a primitive sequence of order n over \(\mathbf {Z}/(m)\) with period T. Then for any integer h we have

$$\begin{aligned} \left| \sum _{t=0}^{T-1}e_{m}\left( a\left( t\right) \right) e_{T}\left( ht\right) \right| \le m^{\frac{n}{2}}\text {.} \end{aligned}$$
(2)

In particular,

$$\begin{aligned} \left| \sum _{t=0}^{T-1}e_{m}\left( a\left( t\right) \right) \right| \le m^{\frac{n}{2}}\text {.} \end{aligned}$$

Moreover, we have

$$\begin{aligned} \left| \sum _{t=k}^{k+L-1}e_{m}\left( a\left( t\right) \right) \right| \le m^{\frac{n}{2}}\left( \frac{4\ln T}{\pi ^{2}}+0.409+\frac{L+1}{T}\right) \end{aligned}$$
(3)

for any integer \(k\ge 0\) and \(0<L<T\).

Proof

Since the inequality (2) has been proved in [14, Theorem 13], we only prove the inequality (3). We start from the identity

$$\begin{aligned} \sum _{t=k}^{k+L-1}e_{m}\left( a\left( t\right) \right) =\sum _{t=k}^{k+T-1}e_{m}\left( a\left( t\right) \right) \sum _{j=0}^{L-1} \frac{1}{T}\sum _{h=0}^{T-1}e_{T}\left( h\left( t-k-j\right) \right) \text { for }k\ge 0\text { and }0<L<T\text {,} \end{aligned}$$

which is valid since the sum over j is 1 for \(k\le t\le k+L-1\) and 0 for \(k+L\le t\le k+T-1\). Rearranging terms, we get

$$\begin{aligned} \sum _{t=k}^{k+L-1}e_{m}\left( a\left( t\right) \right) =\frac{1}{T} \sum _{h=0}^{T-1}\left( \sum _{t=k}^{k+T-1}e_{m}\left( a\left( t\right) \right) e_{T}\left( ht\right) \right) \left( \sum _{j=0}^{L-1}e_{T}\left( -h\left( k+j\right) \right) \right) \text {,} \end{aligned}$$

and so we obtain

$$\begin{aligned} \left| \sum _{t=k}^{k+L-1}e_{m}\left( a\left( t\right) \right) \right|\le & {} \frac{1}{T}\sum _{h=0}^{T-1}\left| \sum _{t=k}^{k+T-1}e_{m}\left( a\left( t\right) \right) e_{T}\left( ht\right) \right| \left| \sum _{j=0}^{L-1}e_{T}\left( -h\left( k+j\right) \right) \right| \\= & {} \frac{1}{T}\sum _{h=0}^{T-1}\left| \sum _{t=0}^{T-1}e_{m}\left( a\left( t\right) \right) e_{T}\left( ht\right) \right| \left| \sum _{j=0}^{L-1}e_{T}\left( -hj\right) \right| \text {.} \end{aligned}$$

Then by the inequality (2) we get

$$\begin{aligned} \left| \sum _{t=k}^{k+L-1}e_{m}\left( a\left( t\right) \right) \right|\le & {} \frac{m^{\frac{n}{2}}}{T}\sum _{h=0}^{T-1}\left| \sum _{j=0}^{L-1}e_{T}\left( -hj\right) \right| \nonumber \\= & {} \frac{m^{\frac{n}{2}}}{T}\sum _{h=0}^{T-1}\left| \sum _{j=0}^{L-1}e_{T}\left( hj\right) \right| \nonumber \\\le & {} \frac{m^{\frac{n}{2}}}{T}\sum _{h=1}^{T-1}\left| \sum _{j=0}^{L-1}e_{T}\left( hj\right) \right| +\frac{L\cdot m^{\frac{n}{2}}}{T}. \end{aligned}$$
(4)

We note that

$$\begin{aligned} \sum _{h=1}^{T-1}\left| \sum _{j=0}^{L-1}e_{T}\left( hj\right) \right|= & {} \sum _{h=1}^{T-1}\left| \frac{e_{T}(hL)-1}{e_{T}(h)-1}\right| \\= & {} \sum _{h=1}^{T-1}\left| \frac{\cos (2\pi hL/T)+i\sin (2\pi hL/T)-1}{\cos (2\pi h/T)+i\sin (2\pi h/T)-1}\right| \\= & {} \sum _{h=1}^{T-1}\left| \frac{-2\sin ^{2}(\pi hL/T)+2i\sin (\pi hL/T)\cos (\pi hL/T)}{-2\sin ^{2}(\pi h/T)+2i\sin (\pi h/T)\cos (\pi h/T)}\right| \\= & {} \sum _{h=1}^{T-1}\left| \frac{\sin (\pi hL/T)}{\sin (\pi h/T)}\right| \text {,} \end{aligned}$$

and so an application of Lemma 3 yields

$$\begin{aligned} \sum _{h=1}^{T-1}\left| \sum _{j=0}^{L-1}e_{T}\left( hj\right) \right|< & {} \frac{4}{\pi ^{2}}T\ln T+0.38T+0.608+0.116\frac{g^{2}}{T} \nonumber \\< & {} \frac{4}{\pi ^{2}}T\ln T+0.409T+1, \end{aligned}$$
(5)

where the last inequality follows from the fact that \(g=\gcd (L,T)<T/2\). Combining the inequalities (4) and (5), we get the desired result.

3 Main Results

Throughout the rest of this paper, we always assume that \(M>1\) is a given square-free odd integer and \(M=p_{1}p_{2}\cdots p_{r}\) is the canonical factorization of M. Let \(d>1\) be a divisor of M. Suppose \(d=p_{i_{1}}\cdots p_{i_{k}}\) with \(1\le i_{1}<\cdots <i_{k}\le r\). Let us denote by \(\lambda _{n}(d)\) the period of primitive sequences of order n over \(\mathbf {Z}/(d)\), that is,

$$ \lambda _{n}(d)=\text {lcm}(p_{i_{1}}^{n}-1,\ldots ,p_{i_{k}}^{n}-1). $$

The main results of this paper are stated in the following Theorems 1 and 2.

Theorem 1

Let \(\underline{a}\) be a primitive sequence of order n over \(\mathbf {Z}/(M)\) with period \(T=\lambda _{n}\left( M\right) \), and let \(\underline{b}=\left[ \underline{a}\right] _{\text {mod}\, 2}\). For \(s\in \left\{ 0,1\right\} \), denote by \(N\left( \underline{b}^{T},s\right) \) the number of t, \(0\le t\le T-1\), with \(b\left( t\right) =s\). Then we have

$$\begin{aligned} \frac{N\left( \underline{b}^{T},s\right) }{T}=\frac{1}{2}+\left( -1\right) ^{s}\cdot \frac{M^{n-1}-1}{2M^{n}-2} \end{aligned}$$
(6)

if M is an odd prime number; and

$$\begin{aligned} \left| \frac{N\left( \underline{b}^{T},s\right) }{T}-\frac{M+1-2s}{2M} \right| <\frac{1}{M}\sum _{\begin{array}{c} d\mid M \\ d>1 \end{array}}\frac{d^{n/2}}{ \lambda _{n}\left( d\right) }\cdot \left( \frac{d\ln d}{\pi }+0.538d\right) \end{aligned}$$
(7)

if M has at least two different prime divisors.

Theorem 2

Let \(\underline{a}\) be a primitive sequence of order n over \(\mathbf {Z}/(M)\) with period \(T=\lambda _{n}\left( M\right) \). Let \( \underline{b}=\left[ \underline{a}\right] _{\text {mod}\, 2}\) and \(\underline{b} ^{L}=\left( b\left( k\right) ,b\left( k+1\right) ,\ldots ,b\left( k+L-1\right) \right) \) a segment of \(\underline{b}\) with length \(L=\mu T\), where \(0\le k\le T-1\) and \(0<\mu <1\). For \(s\in \left\{ 0,1\right\} \), denote by \(N\left( \underline{b}^{L},s\right) \) the number of t, \(0\le t\le L-1\), with \(b\left( k+t\right) =s\). Then we have

$$\begin{aligned} \left| \frac{N\left( \underline{b}^{L},s\right) }{L}-\frac{M+1-2s}{2M} \right| <\frac{1}{M}\sum _{\begin{array}{c} d\mid M \\ d>1 \end{array}}\frac{d^{\frac{n}{2} }}{\lambda _{n}\left( d\right) }C\left( d,L\right) \text {,} \end{aligned}$$

where

$$\begin{aligned} C\left( d,L\right) =\left( \frac{\lambda _{n}\left( d\right) }{L}\left( \frac{4}{\pi ^{2}}\ln \lambda _{n}\left( d\right) +0.409\right) +\frac{L+1}{L}\right) \left( \frac{d\ln d}{\pi }+0.538d\right) \text {.} \end{aligned}$$

The rest of this section is divided into three subsections. Subsects. 3.1 and 3.2 are mainly devoted to the proof of Theorem 1 and the proof of Theorem 2, respectively. Finally, as an example, an application of Theorems 1 and 2 to the modulo 2 reductions of primitive sequences over \(\mathbf {Z}/(2^{32}-1)\) is given in Subsect. 3.3.

3.1 The Proof of Theorem 1

We first collect two well-known results on trigonometric functions in Lemma 3. The first result can be found in [19] and the second result can be found in [11, p. 447].

Lemma 3

Let \(\tan x=\sin x/\cos x\), \(\sec x=1/\cos x\) and \(\csc x=1/\sin x\) be the tangent function, the secant function and the cosecant function, respectively. Then we have:

(1) \(\int \sec xdx=\ln \left| \sec x+\tan x\right| +C\), where C is the constant of integration;

(2) \(\csc (\pi /m)\le m/3\) if \(m\ge 6\).

Lemma 4

For an odd integer \(m>1\), we have

$$\begin{aligned} \sum _{h=1}^{m-1}\left| \sec \frac{h\pi }{m}\right| <\frac{2}{\pi } m\ln m+1.076m\text {.} \end{aligned}$$

Proof

It can be directly verified that the lemma holds for \(m=3\) or 5. Therefore, we assume that \(m\ge 7\). Since it is clear that

$$\begin{aligned} \sec \frac{h\pi }{m}=-\sec \frac{\left( m-h\right) \cdot \pi }{m}>0\text { for }1\le h\le \frac{m-1}{2}, \end{aligned}$$

we obtain

$$\begin{aligned} \sum _{h=1}^{m-1}\left| \sec \frac{h\pi }{m}\right| =2\sum _{h=1}^{ \frac{m-1}{2}}\sec \frac{h\pi }{m}\text {.} \end{aligned}$$
(8)

Note that the convexity of the function \(\sec x\) implies that

$$\begin{aligned} \int _{u-\frac{\theta }{2}}^{u+\frac{\theta }{2}}\sec xdx>\theta \cdot \sec u \text { for }\frac{\theta }{2}<u<\frac{\pi }{2}-\frac{\theta }{2}\text {.} \end{aligned}$$

Thus by taking \(\theta =\frac{\pi }{m}\) we get

$$\begin{aligned} \sum _{h=1}^{\frac{m-3}{2}}\sec \frac{h\pi }{m}< & {} \frac{m}{\pi }\sum _{h=1}^{\frac{m-3}{2}}\int _{\frac{h\pi }{m}-\frac{\pi }{2m}}^{\frac{h\pi }{m}+\frac{\pi }{2m}}\sec xdx \nonumber \\= & {} \frac{m}{\pi }\int _{\frac{\pi }{2m}}^{\frac{\left( m-2\right) \cdot \pi }{ 2m}}\sec xdx \nonumber \\< & {} \frac{m}{\pi }\int _{0}^{\frac{\left( m-2\right) \cdot \pi }{2m}}\sec xdx \nonumber \\= & {} \frac{m}{\pi }\cdot \ln \left( \sec \frac{\left( m-2\right) \cdot \pi }{2m}+\tan \frac{\left( m-2\right) \cdot \pi }{2m}\right) \nonumber \\= & {} \frac{m}{\pi }\cdot \left( \ln \left( \sec \frac{\left( m-2\right) \cdot \pi }{2m}\right) +\ln \left( 1+\sin \frac{\left( m-2\right) \cdot \pi }{2m}\right) \right) \nonumber \\< & {} \frac{m}{\pi }\cdot \left( \ln \left( \csc \frac{\pi }{m}\right) +\ln 2\right) \text {.} \end{aligned}$$
(9)

By combining (8) and (9), we obtain

$$\begin{aligned} \sum _{h=1}^{m-1}\left| \sec \frac{h\pi }{m}\right|< & {} \frac{2m}{\pi }\cdot \left( \ln \left( \csc \frac{\pi }{m}\right) +\ln 2\right) +2\sec \frac{\left( m-1\right) \pi }{2m} \nonumber \\= & {} \frac{2m}{\pi }\cdot \left( \ln \left( \csc \frac{\pi }{m}\right) +\ln 2\right) +2\csc \frac{\pi }{2m}\text {.} \end{aligned}$$
(10)

By applying \(\csc (\pi /m)\le m/3\) to the right-hand side of (10) we get

$$\begin{aligned} \sum _{h=1}^{m-1}\left| \sec \frac{h\pi }{m}\right|<\frac{2}{\pi } m\ln m+\frac{2m}{\pi }\left( \ln 2-\ln 3\right) +\frac{4}{3}m<\frac{2}{\pi } m\ln m+1.076m. \end{aligned}$$

This completes the proof.

Now we start to prove Theorem 1.

Proof

(Proof of Theorem 1). If M is an odd prime number, then (6) immediately follows from the theory of m-sequences over finite fields (see, for example, [11]). Next we will prove the equality (7). Note that

$$\begin{aligned} \left| \frac{N\left( \underline{b}^{T},0\right) }{T}-\frac{M+1}{2M} \right| =\left| 1-\frac{N\left( \underline{b}^{T},1\right) }{T}-\frac{M+1}{2M}\right| =\left| \frac{N\left( \underline{b}^{T},1\right) }{T}-\frac{M-1}{2M}\right| \text {,} \end{aligned}$$

and so it suffices to show (7) holds for the case that \(s=0\), that is,

$$\begin{aligned} \left| \frac{N\left( \underline{b}^{T},0\right) }{T}-\frac{M+1}{2M}\right| <\frac{1}{M}\sum _{\begin{array}{c} d\mid M \\ d>1 \end{array}}\frac{d^{n/2}}{\lambda _{n}\left( d\right) }\cdot \left( \frac{d\ln d}{\pi }+0.538d\right) \text {.} \end{aligned}$$
(11)

Since

$$\begin{aligned} N\left( \underline{b}^{T},0\right)= & {} \sum \limits _{t=0}^{T-1}\sum _{x=0}^{\frac{M-1}{2}}\left( \frac{1}{M}\sum _{h=0}^{M-1}e_{M}\left( h\left( a\left( t\right) -2x\right) \right) \right) \\= & {} \frac{1}{M}\sum _{h=0}^{M-1}\left( \sum \limits _{t=0}^{T-1}e_{M}\left( ha\left( t\right) \right) \cdot \sum _{x=0}^{\frac{M-1}{2}}e_{M}\left( -2hx\right) \right) \\= & {} \frac{T\cdot \left( M+1\right) }{2M}+\frac{1}{M}\sum _{h=1}^{M-1}\left( \sum \limits _{t=0}^{T-1}e_{M}\left( ha\left( t\right) \right) \cdot \sum _{x=0}^{\frac{M-1}{2}}e_{M}\left( -2hx\right) \right) \text {,} \end{aligned}$$

we get

$$\begin{aligned} \left| \frac{N\left( \underline{b}^{T},0\right) }{T}-\frac{M+1}{2M} \right| \le \frac{1}{MT}\sum _{h=1}^{M-1}\left| \sum \limits _{t=0}^{T-1}e_{M}\left( ha\left( t\right) \right) \right| \cdot \left| \sum _{x=0}^{\frac{M-1}{2}}e_{M}\left( -2hx\right) \right| \text {.} \end{aligned}$$
(12)

We note that

$$\begin{aligned} \sum _{x=0}^{\frac{M-1}{2}}e_{M}\left( -2hx\right)= & {} \frac{\left( e^{-\frac{4h\pi i}{M}}\right) ^{\frac{M+1}{2}}-1}{e^{-\frac{4h\pi i}{M}}-1} \nonumber \\= & {} \frac{e^{-\frac{2h\pi i}{M}}-1}{e^{-\frac{4h\pi i}{M}}-1} \nonumber \\= & {} \frac{1}{e^{-\frac{2h\pi i}{M}}+1} \nonumber \\= & {} \frac{1}{\cos \frac{2h\pi }{M}-i\sin \frac{2h\pi }{M}+1} \nonumber \\= & {} \frac{1}{2\cos ^{2}\frac{h\pi }{M}-2i\sin \frac{h\pi }{M}\cos \frac{h\pi }{M}} \nonumber \\= & {} \frac{1}{2}\cdot \frac{\sec \frac{h\pi }{M}}{e^{-\frac{h\pi i}{M}}}\text {.} \end{aligned}$$
(13)

Applying (13) to (12) we obtain

$$\begin{aligned} \left| \frac{N\left( \underline{b}^{T},0\right) }{T}-\frac{M+1}{2M} \right|\le & {} \frac{1}{2MT}\sum _{h=1}^{M-1}\left| \sum \limits _{t=0}^{T-1}e_{M}\left( ha\left( t\right) \right) \right| \cdot \left| \sec \frac{h\pi }{M}\right| \nonumber \\= & {} \frac{1}{2MT}\sum _{\begin{array}{c} d\mid M \\ d>1 \end{array}}\sum _{_{\begin{array}{c} 1\le h\le M-1 \\ \gcd \left( h,M\right) =M/d \end{array}}}\left| \sum \limits _{t=0}^{T-1}e_{M}\left( ha\left( t\right) \right) \right| \cdot \left| \sec \frac{h\pi }{M}\right| \nonumber \\= & {} \frac{1}{2MT}\sum _{\begin{array}{c} d\mid M \\ d>1 \end{array}}\sum _{_{\begin{array}{c} 1\le h\le d-1 \\ \gcd \left( h,d\right) =1 \end{array}}}\left| \sum \limits _{t=0}^{T-1}e_{d}\left( ha\left( t\right) \right) \right| \cdot \left| \sec \frac{h\pi }{d}\right| . \end{aligned}$$
(14)

Note that given a divisor \(d>1\) of M, \(\left[ h\underline{a}\right] _{\text {mod}\, d}\) is a primitive sequence over \(\mathbf {Z}/(d)\) with period \(\lambda _{n}\left( d\right) \) for every integer h coprime with d, and so it follows from Lemma 2 that

$$\begin{aligned} \left| \sum \limits _{t=0}^{T-1}e_{d}\left( ha\left( t\right) \right) \right| =\left| \frac{T}{\lambda _{n}\left( d\right) }\cdot \sum \limits _{t=0}^{\lambda _{n}\left( d\right) -1}e_{d}\left( ha\left( t\right) \right) \right| \le \frac{T\cdot d^{n/2}}{\lambda _{n}\left( d\right) }\text {.} \end{aligned}$$
(15)

Combining (14) and (15) yields

$$\begin{aligned} \left| \frac{N\left( \underline{b}^{T},0\right) }{T}-\frac{M+1}{2M}\right|\le & {} \frac{1}{2MT}\sum _{\begin{array}{c} d\mid M \\ d>1 \end{array}}\sum _{ _{\begin{array}{c} 1\le h\le d-1 \\ \gcd \left( h,d\right) =1 \end{array}}}\frac{T\cdot d^{n/2}}{\lambda _{n}\left( d\right) }\cdot \left| \sec \frac{h\pi }{d}\right| \nonumber \\= & {} \frac{1}{2M}\sum _{\begin{array}{c} d\mid M \\ d>1 \end{array}}\frac{d^{n/2}}{\lambda _{n}\left( d\right) }\cdot \sum _{_{\begin{array}{c} 1\le h\le d-1 \\ \gcd \left( h,d\right) =1 \end{array}}}\left| \sec \frac{h\pi }{d}\right| \nonumber \\\le & {} \frac{1}{2M}\sum _{\begin{array}{c} d\mid M \\ d>1 \end{array}}\frac{d^{n/2}}{\lambda _{n}\left( d\right) }\cdot \sum _{h=1}^{d-1}\left| \sec \frac{h\pi }{d} \right| \text {,} \end{aligned}$$
(16)

and so (11) follows from (16) and Lemma 4.

Generally speaking, if n is sufficiently large, then the right-hand side of (6) is sufficiently small, and so the value of \(N\left( \underline{b}^{T},s\right) /T\) is very close to that of \(\left( M+1-2s\right) /2M\) (for more details, see Table 1). In fact, we can give a more theoretical result on the asymptotic property of \(N\left( \underline{b} ^{T},s\right) /T\) as \(n\rightarrow \infty \).

Corollary 1

Let \(\underline{a}\) be a primitive sequence of order n over \(\mathbf {Z}/(M)\) with period \(T=\lambda _{n}\left( M\right) \), and let \(\underline{b}=\left[ \underline{a}\right] _{\text {mod}\, 2}\). Then for \(s\in \left\{ 0,1\right\} \) we have

$$\begin{aligned} \lim _{n\rightarrow \infty }\frac{N\left( \underline{b}^{T},s\right) }{T}=\frac{M+1-2s}{2M}\text {.} \end{aligned}$$

To prove Corollary 1, we first introduce a result of Bugeaud, Corvaja and Zannier [1].

Lemma 5

([1, Theorem 1]) If \(a<b\) are two integers greater than 1 which are multiplicatively independent (that is, the only integer solution \(\left( x,y\right) \) of the equation \(a^{x}b^{y}=1\) is \(\left( x,y\right) =\left( 0,0\right) )\), then for any given real number \(\varepsilon >0\), there exists an integer \(N_{\varepsilon }\) such that

$$\begin{aligned} \gcd \left( a^{n}-1,b^{n}-1\right) <a^{n\varepsilon }\text { for all integers }n>N_{\varepsilon }\text {.} \end{aligned}$$

Remark 1

Note that a and b are multiplicatively independent if \(\gcd \left( a,b\right) =1\).

Proof

(Proof of Corollary 1). Since Corollary 1 is obvious true for the case that M is an odd prime number, we assume that \(M=p_{1}p_{2}\cdots p_{r}\) is the canonical factorization of M with \(r\ge 2\) and \(3\le p_{1}<p_{2}<\cdots <p_{r}\). Note that the inequality

$$\begin{aligned} \frac{d\ln d}{\pi }+0.538d\le \frac{M\ln M}{\pi }+0.538M \end{aligned}$$

holds for any divisor d of M, and so by Theorem 1 we get

$$\begin{aligned} \left| \frac{N\left( \underline{v}^{T},s\right) }{T}-\frac{M+1-2s}{2M} \right| <\left( \frac{M\ln M}{\pi }+0.538M\right) \cdot \sum _{\begin{array}{c} d\mid M \\ d>1 \end{array}}\frac{d^{n/2}}{\lambda _{n}\left( d\right) }\text {.} \end{aligned}$$

Therefore to prove Corollary 1, it suffices to show that

$$\begin{aligned} \lim _{n\rightarrow \infty }\sum _{\begin{array}{c} d\mid M \\ d>1 \end{array}}\frac{d^{n/2}}{\lambda _{n}\left( d\right) }=0\text {,} \end{aligned}$$

that is

$$\begin{aligned} \lim _{n\rightarrow \infty }\sum _{k=1}^{r}\sum _{1\le i_{1}<\cdots <i_{k}\le r}\frac{\prod _{j=1}^{k}p_{i_{j}}^{n/2}}{\text {lcm}\left( p_{i_{1}}^{n}-1,p_{i_{2}}^{n}-1,\ldots ,p_{i_{k}}^{n}-1\right) }=0\text {.} \end{aligned}$$
(17)

Given a real number \(\varepsilon >0\). For any \(1\le u<v\le r\), it follows from Lemma 5 and Remark 1 that there exists an integer \(N_{\varepsilon }^{(u,v)}\) such that

$$\begin{aligned} \gcd \left( p_{u}^{n}-1,p_{v}^{n}-1\right) <p_{u}^{n\varepsilon }\text { for all integers }n>N_{\varepsilon }^{(u,v)}\text {.} \end{aligned}$$

Set

$$\begin{aligned} N_{\varepsilon }=\max \{\left\lceil \frac{\ln p_{u}}{\ln p_{1}}\cdot N_{\varepsilon }^{(u,v)}\right\rceil \mid 1\le u<v\le r\}\text {,} \end{aligned}$$

where \(\left\lceil a\right\rceil \) denotes the smallest integer greater than or equal to a. Then it is clear that

$$\begin{aligned} \gcd \left( p_{u}^{n}-1,p_{v}^{n}-1\right)<p_{1}^{n\varepsilon }\text {, } 1\le u<v\le r\text { and }n>N_{\varepsilon }. \end{aligned}$$
(18)

Let \(2\le k\le r\) and \(1\le i_{1}<\cdots <i_{k}\le r\). It follows from (18) that if \(n>N_{\varepsilon }\), then

$$\begin{aligned} \text {lcm}\left( p_{i_{1}}^{n}-1,p_{i_{2}}^{n}-1,\ldots ,p_{i_{k}}^{n}-1\right)\ge & {} \frac{\prod _{j=1}^{k}(p_{i_{j}}^{n}-1)}{\prod \nolimits _{1\le j<l\le k}\gcd (p_{i_{j}}^{n}-1,p_{i_{l}}^{n}-1)} \\> & {} p_{1}^{-k^{2}n\varepsilon /2}\cdot \prod \nolimits _{j=1}^{k}(p_{i_{j}}^{n}-1) \\\ge & {} p_{1}^{-r^{2}n\varepsilon /2}\cdot \prod \nolimits _{j=1}^{k}(p_{i_{j}}^{n}-1). \end{aligned}$$

Consequently, we have

$$\begin{aligned} \frac{\prod _{j=1}^{k}p_{i_{j}}^{n/2}}{\text {lcm}\left( p_{i_{1}}^{n}-1,p_{i_{2}}^{n}-1,\ldots ,p_{i_{k}}^{n}-1\right) }\le & {} p_{1}^{r^{2}n\varepsilon /2}\cdot \prod \nolimits _{j=1}^{k}\frac{p_{i_{j}}^{n/2}}{p_{i_{j}}^{n}-1} \nonumber \\< & {} p_{1}^{r^{2}n\varepsilon /2}\cdot \prod \nolimits _{j=1}^{k}p_{i_{j}}^{1-n/2} \nonumber \\\le & {} p_{1}^{r^{2}n\varepsilon /2}\cdot M\cdot \prod \nolimits _{j=1}^{k}p_{i_{j}}^{-n/2}\text {.} \end{aligned}$$
(19)

Note that \(k\ge 2\) and \(p_{i_{j}}\ge p_{1}\) for \(1\le j\le k\), and so (19) yields

$$\begin{aligned} \frac{\prod _{j=1}^{k}p_{i_{j}}^{n/2}}{\text {lcm}\left( p_{i_{1}}^{n}-1,p_{i_{2}}^{n}-1,\ldots ,p_{i_{k}}^{n}-1\right) }< & {} p_{1}^{r^{2}n\varepsilon /2}\cdot M\cdot p_{1}^{-nk/2} \\\le & {} p_{1}^{r^{2}n\varepsilon /2}\cdot M\cdot p_{1}^{-n} \\= & {} M\cdot p_{1}^{-\frac{n}{2}\cdot (2-r^{2}\varepsilon )}\text {.} \end{aligned}$$

Hence it can be seen that

$$\begin{aligned}&\sum _{k=1}^{r}\sum _{1\le i_{1}<\cdots<i_{k}\le r}\frac{\prod _{j=1}^{k}p_{i_{j}}^{n/2}}{\text {lcm}\left( p_{i_{1}}^{n}-1,p_{i_{2}}^{n}-1,\ldots ,p_{i_{k}}^{n}-1\right) } \\= & {} \sum _{i=1}^{r}\frac{p_{i}^{n/2}}{p_{i}^{n}-1}+\sum _{k=2}^{r}\sum _{1\le i_{1}<\cdots<i_{k}\le r}\frac{\prod _{j=1}^{k}p_{i_{j}}^{n/2}}{\text {lcm}\left( p_{i_{1}}^{n}-1,p_{i_{2}}^{n}-1,\ldots ,p_{i_{k}}^{n}-1\right) } \\< & {} \frac{r}{p_{1}^{n/2}-1}+2^{r}\cdot M\cdot p_{1}^{-\frac{n}{2}\cdot \left( 2-r^{2}\varepsilon \right) }\text {.} \end{aligned}$$

Then choosing \(\varepsilon <r^{-2}\), we get

$$\begin{aligned} 0\le \sum _{k=1}^{r}\sum _{1\le i_{1}<\cdots<i_{k}\le r}\frac{\prod _{j=1}^{k}p_{i_{j}}^{n/2}}{\text {lcm}\left( p_{i_{1}}^{n}-1,p_{i_{2}}^{n}-1,\ldots ,p_{i_{k}}^{n}-1\right) }<\frac{r}{p_{1}^{n/2}-1}+2^{r}\cdot M\cdot p_{1}^{-n/2}\text {.} \end{aligned}$$
(20)

Since r, M and \(p_{1}\) are all fixed integers with \(p_{1}\ge 3\), we get

$$\begin{aligned} \lim _{n\rightarrow \infty }\frac{r}{p_{1}^{n/2}-1}+2^{r}\cdot M\cdot p_{1}^{-n/2}=0\text {,} \end{aligned}$$

and so (17) follows from (20).

3.2 The Proof of Theorem 2

Proof

(Proof of Theorem 2). Since

$$\begin{aligned} \left| \frac{N\left( \underline{b}^{L},0\right) }{L}-\frac{M+1}{2M} \right| =\left| \frac{N\left( \underline{b}^{L},1\right) }{L}-\frac{M-1}{2M}\right| \text {,} \end{aligned}$$

it suffices to show that

$$\begin{aligned} \left| \frac{N\left( \underline{b}^{L},0\right) }{L}-\frac{M+1}{2M} \right| <\frac{1}{M}\sum _{\begin{array}{c} d\mid M \\ d>1 \end{array}}\frac{d^{\frac{n}{2}}}{\lambda _{n}\left( d\right) }C\left( d,L\right) \text {.} \end{aligned}$$
(21)

First, it is clear that

$$\begin{aligned} N\left( \underline{b}^{L},0\right)= & {} \sum \limits _{t=k}^{k+L-1}\sum _{x=0}^{\frac{M-1}{2}}\left( \frac{1}{M}\sum _{h=0}^{M-1}e_{M}\left( h\left( a\left( t\right) -2x\right) \right) \right) \\= & {} \frac{1}{M}\sum _{h=0}^{M-1}\left( \sum \limits _{t=k}^{k+L-1}e_{M}\left( ha\left( t\right) \right) \cdot \sum _{x=0}^{\frac{M-1}{2}}e_{M}\left( -2hx\right) \right) \\= & {} \frac{L\cdot \left( M+1\right) }{2M}+\frac{1}{M}\sum _{h=1}^{M-1}\left( \sum \limits _{t=k}^{k+L-1}e_{M}\left( ha\left( t\right) \right) \cdot \sum _{x=0}^{\frac{M-1}{2}}e_{M}\left( -2hx\right) \right) \text {.} \end{aligned}$$

Then proceed as in the proof of Theorem 1, we can get

$$\begin{aligned} \left| \frac{N\left( \underline{b}^{T},0\right) }{L}-\frac{M+1}{2M} \right| \le \frac{1}{2ML}\sum _{\begin{array}{c} d\mid M \\ d>1 \end{array}}\sum _{ _{\begin{array}{c} 1\le h\le d-1 \\ \gcd \left( h,d\right) =1 \end{array}}}\left| \sum \limits _{t=k}^{k+L-1}e_{d}\left( ha\left( t\right) \right) \right| \cdot \left| \sec \frac{h\pi }{d}\right| . \end{aligned}$$
(22)

Note that given a divisor \(d>1\) of M, \(\left[ h\underline{a}\right] _{ \text {mod}\, d}\) is a primitive sequence over \(\mathbf {Z}/(d)\) with period \( \lambda _{n}\left( d\right) \) for every integer h coprime with d, and so by Lemma 2 we have

$$\begin{aligned} \left| \sum \limits _{t=k}^{k+L-1}e_{d}\left( ha\left( t\right) \right) \right|= & {} \left| \sum \limits _{t=k}^{k+\left[ L\right] _{\text {mod}\, \lambda _{n}\left( d\right) }-1}e_{d}\left( ha\left( t\right) \right) +\left\lfloor \frac{L}{\lambda _{n}\left( d\right) }\right\rfloor \cdot \sum \limits _{t=0}^{\lambda _{n}\left( d\right) -1}e_{d}\left( ha\left( t\right) \right) \right| \nonumber \\\le & {} \left| \sum \limits _{t=k}^{k+\left[ L\right] _{\text {mod}\, \lambda _{n}\left( d\right) }-1}e_{d}\left( ha\left( t\right) \right) \right| +\left\lfloor \frac{L}{\lambda _{n}\left( d\right) }\right\rfloor \cdot \left| \sum \limits _{t=0}^{\lambda _{n}\left( d\right) -1}e_{d}\left( ha\left( t\right) \right) \right| \nonumber \\\le & {} d^{\frac{n}{2}}\left( \frac{4\ln \lambda _{n}\left( d\right) }{\pi ^{2}}+0.409+\frac{\left[ L\right] _{\text {mod}\, \lambda _{n}\left( d\right) }+1 }{\lambda _{n}\left( d\right) }\right) +\left\lfloor \frac{L}{\lambda _{n}\left( d\right) }\right\rfloor \cdot d^{\frac{n}{2}} \nonumber \\= & {} d^{\frac{n}{2}}\left( \frac{4\ln \lambda _{n}\left( d\right) }{\pi ^{2}} +0.409+\frac{L+1}{\lambda _{n}\left( d\right) }\right) \text {,} \end{aligned}$$
(23)

where \(\left\lfloor a\right\rfloor \) denotes the largest integer smaller than or equal to a. Combining (22) and (23) we get

$$\begin{aligned}&\left| \frac{N\left( \underline{b}^{T},0\right) }{L}-\frac{M+1}{2M} \right| \nonumber \\\le & {} \frac{1}{2M}\sum _{\begin{array}{c} d\mid M \\ d>1 \end{array}}\sum _{_{\begin{array}{c} 1\le h\le d-1 \\ \gcd \left( h,d\right) =1 \end{array}}}\frac{d^{\frac{n}{2}}}{\lambda _{n}\left( d\right) }\left( \frac{\lambda _{n}\left( d\right) }{L}\left( \frac{4}{\pi ^{2}}\ln \lambda _{n}\left( d\right) +0.409\right) +\frac{L+1}{L}\right) \cdot \left| \sec \frac{h\pi }{d}\right| \nonumber \\\le & {} \frac{1}{2M}\sum _{\begin{array}{c} d\mid M \\ d>1 \end{array}}\frac{d^{\frac{n}{2}}}{\lambda _{n}\left( d\right) }\left( \frac{\lambda _{n}\left( d\right) }{L} \left( \frac{4}{\pi ^{2}}\ln \lambda _{n}\left( d\right) +0.409\right) + \frac{L+1}{L}\right) \cdot \sum _{h=1}^{d-1}\left| \sec \frac{h\pi }{d} \right| \text {.} \end{aligned}$$
(24)

and so (21) follows from (24) and Lemma 4.

Similar to Corollary 1, we can give the asymptotic property of \(\frac{N\left( \underline{b}^{L},s\right) }{L}\) as \(n\rightarrow \infty \).

Corollary 2

Let \(\underline{a}\) be a primitive sequence of order n over \(\mathbf {Z}/(M)\) with period \(T=\lambda _{n}\left( M\right) \). Let \( \underline{b}=\left[ \underline{a}\right] _{\text {mod}\, 2}\) and \(\underline{b} ^{L}=\left( b\left( k\right) ,b\left( k+1\right) ,\ldots ,b\left( k+L-1\right) \right) \) a segment of \(\underline{b}\) with length \(L=\mu T\), where \(0\le k\le T-1\) and \(0<\mu <1\). Then for \(s\in \left\{ 0,1\right\} \) we have

$$\begin{aligned} \lim _{n\rightarrow \infty }\frac{N\left( \underline{b}^{L},s\right) }{L}= \frac{M+1-2s}{2M}\text {.} \end{aligned}$$

Proof

Since

$$\begin{aligned} \frac{\lambda _{n}\left( d\right) }{L}\left( \frac{4}{\pi ^{2}}\ln \lambda _{n}\left( d\right) +0.409\right) +\frac{L+1}{L}< & {} \frac{\lambda _{n}\left( M\right) }{L}\left( \frac{4}{\pi ^{2}}\ln M^{n}+0.409\right) +2 \\= & {} \frac{1}{\mu }\left( \frac{4}{\pi ^{2}}n\ln M+0.409\right) +2 \\< & {} \left( \frac{4\ln M}{\mu \pi ^{2}}+\frac{3}{\mu }\right) \cdot n \end{aligned}$$

and

$$\begin{aligned} \frac{d\ln d}{\pi }+0.538d\le \frac{M\ln M}{\pi }+0.538M \end{aligned}$$

hold for any divisor d of M with \(d>1\), it follows from Theorem 2 that

$$\begin{aligned} \left| \frac{N\left( \underline{b}^{L},s\right) }{L}-\frac{M+1-2s}{2M} \right| <D_{\mu }\left( M\right) \sum _{\begin{array}{c} d\mid M \\ d>1 \end{array}}\frac{ nd^{\frac{n}{2}}}{\lambda _{n}\left( d\right) }\text {,} \end{aligned}$$

where

$$\begin{aligned} D_{\mu }\left( M\right) =\left( \frac{4\ln M}{\mu \pi ^{2}}+\frac{3}{\mu } \right) \cdot \left( \frac{M\ln M}{\pi }+0.538M\right) \end{aligned}$$

is a constant only depended on M and \(\mu \). Therefore to prove Corollary 2, it suffices to show that

$$\begin{aligned} \lim _{n\rightarrow \infty }\sum _{\begin{array}{c} d\mid M \\ d>1 \end{array}}\frac{nd^{\frac{n }{2}}}{\lambda _{n}\left( d\right) }=0\text {,} \end{aligned}$$

that is

$$\begin{aligned} \lim _{n\rightarrow \infty }\sum _{k=1}^{r}\sum _{1\le i_{1}<\cdots <i_{k}\le r}\frac{n\prod _{j=1}^{k}p_{i_{j}}^{n/2}}{\text {lcm}\left( p_{i_{1}}^{n}-1,p_{i_{2}}^{n}-1,\ldots ,p_{i_{k}}^{n}-1\right) }=0\text {.} \end{aligned}$$
(25)

Proceed as in the proof of Corollary 1 (but substitute \( \prod _{j=1}^{k}p_{i_{j}}^{n/2}\) by \(n\prod _{j=1}^{k}p_{i_{j}}^{n/2}\)), finally we can get

$$\begin{aligned} 0\le \sum _{k=1}^{r}\sum _{1\le i_{1}<\cdots<i_{k}\le r}\frac{ n\prod _{j=1}^{k}p_{i_{j}}^{n/2}}{\text {lcm}\left( p_{i_{1}}^{n}-1,p_{i_{2}}^{n}-1,\ldots ,p_{i_{k}}^{n}-1\right) }<\frac{rn}{ p_{1}^{n/2}-1}+2^{r}M\cdot np_{1}^{-n/2}\text {.} \end{aligned}$$
(26)

Since r, M and \(p_{1}\) are all fixed integers with \(p_{1}\ge 3\), we get

$$\begin{aligned} \lim _{n\rightarrow \infty }\frac{rn}{p_{1}^{n/2}-1}+2^{r}M\cdot np_{1}^{-n/2}=0\text {,} \end{aligned}$$

and so (25) follows from (26).

3.3 An Example: Element Distribution of Modulo 2 Reductions of Primitive Sequences over \(\mathbf {Z}/(2^{32}-1)\)

Let \(\underline{a}\) be a primitive sequence of order n over \(\mathbf {Z} /(2^{32}-1)\) with period \(T=\lambda _{n}\left( 2^{32}-1\right) \). Let \( \underline{b}=\left[ \underline{a}\right] _{\text {mod}\, 2}\) and \(\underline{b} ^{L}=\left( b\left( k\right) ,b\left( k+1\right) ,\ldots ,b\left( k+L-1\right) \right) \) a segment of \(\underline{b}\) with length \(L=\mu T\), where \(0\le k<T\) and \(0<\mu \le 1\). Then it follows from Theorems 1 and 2 that

$$\begin{aligned} \left| \frac{N\left( \underline{b}^{L},s\right) }{L}-\frac{2^{31}-s}{ 2^{32}-1}\right| <\varLambda _{n}\left( \mu \right) \text {,} \end{aligned}$$
(27)

where

$$ \varLambda _{n}\left( \mu \right) =\left\{ \begin{array}{l} \frac{1}{2^{32}-1}\sum \limits _{\begin{array}{c} d\mid 2^{32}-1 \\ d>1 \end{array}}\frac{ d^{n/2}}{\lambda _{n}\left( d\right) }B\left( d\right) \text {, if }\mu =1 \text {;} \\ \frac{1}{2^{32}-1}\sum \limits _{\begin{array}{c} d\mid 2^{32}-1 \\ d>1 \end{array}}\frac{ d^{n/2}}{\lambda _{n}\left( d\right) }C\left( d,\mu T\right) \text {, if } 0<\mu <1\text {,} \end{array} \right. $$

with

$$ B\left( d\right) =\frac{d\ln d}{\pi }+0.538d $$

and

$$ C\left( d,\mu T\right) =\left( \frac{\lambda _{n}\left( d\right) }{L}\left( \frac{4}{\pi ^{2}}\ln \lambda _{n}\left( d\right) +0.409\right) \right) \cdot B\left( d\right) \text {.} $$

The values of \(\varLambda _{n}\left( \mu \right) \) are calculated and listed in Table 1 for \(1\le n\le 10\) and \(\mu \in \left\{ 1,1/2,1/4,1/8\right\} \). It can be seen from Table 1 that the estimate of (27) is nontrivial if \(\left( 1\right) \) \(\mu =1\) and \(n\ge 2\); or \(\left( 2\right) \) \(0<\mu <1\) and \(n\ge 3\). Moreover for any \(\mu \in \left\{ 1,1/2,1/4,1/8\right\} \), the value of \(\varLambda _{n}\left( \mu \right) \) is very close to 0 if \(n\ge 3\), which is consistent with the results of Corollarys 1 and 2.

Table 1. The values of \(\varLambda _{n}\left( \mu \right) \text { for }1\le n\le 10\text { and }\mu \in \left\{ 1,1/2,1/4,1/8\right\} \)

4 Conclusions

In this paper, the distribution properties of modulo 2 reductions of primitive sequences modulo square-free odd integers are studied. Let M be a square-free odd integer, n a positive integer, and \(\underline{a}\) a primitive sequence of order n over \(\mathbf {Z}/(M)\) with period T. For \( s\in \left\{ 0,1\right\} \) and \(0<\mu \le 1\), denote by \(f_{s}\) the proportion of occurrences of s within a segment of the binary sequence \( \left[ \underline{a}\right] _{\text {mod}\, 2 }\), the modulo 2 reduction of \( \underline{a}\), of length \(\mu T\). Then it is shown that the difference of \( f_{s}\) from the average value \(\frac{M+1-2s}{2M}\) tends to 0 as \( n\rightarrow \infty \). Note that \(\frac{M+1}{2M}\) differs from \(\frac{M-1}{2M }\) by \(\frac{1}{M}\). This implies that there exists a small imbalance between 0 and 1 occurring in the binary sequence \(\left[ \underline{a} \right] _{\text {mod}\, 2}\), and the bias of \(f_{0}\) and \(f_{1}\) is about \(\frac{1}{M} \). To provide a good resistance against the distinguishing attacks, such imbalance should be taken into full consideration in the design of stream ciphers based on \(\left[ \underline{a}\right] _{\text {mod}\, 2}\). A simple method is to introduce the exclusive or operation. A bitwise exclusive or of several phase-shifts of \(\left[ \underline{a}\right] _{\text {mod}\, 2}\) will has smaller bias than \(\left[ \underline{a}\right] _{\text {mod}\, 2}\). Therefore, by introducing a moderate amount of exclusive or operations, the imbalance of 0, 1 will be reduced to a small enough extent. In the future we will be interested in other pseudorandom properties of \(\left[ \underline{a}\right] _{\text {mod}\, 2}\), such as the linear complexity of \(\left[ \underline{a}\right] _{\text {mod}\, 2}\).