## Introduction

Let $$(F_n)_{n \ge 1}$$ be the sequence of Fibonacci numbers, which is defined by the initial conditions $$F_1=F_2=1$$ and by the linear recurrence $$F_n=F_{n-1} + F_{n-2}$$ for $$n \ge 3$$. It is well known  that every positive integer n can be written as a sum of distinct non-consecutive Fibonacci numbers, that is, $$n = \sum _{i=1}^m d_i F_i$$, where $$m \in \mathbb {N}$$, $$d_i \in \{0, 1\}$$, and $$d_i d_{i+1} = 0$$ for all $$i \in \{1, \ldots , m-1\}$$. This is called the Zeckendorf representation of n and, apart from the equivalent use of $$F_1$$ instead of $$F_2$$ or vice versa, is unique.

The Zeckendorf representation of integer sequences has been studied in several works. For instance, Filipponi and Freitag [6, 7] studied the Zeckendorf representation of numbers of the form $$F_{kn}/F_n$$, $$F_n^2/d$$ and $$L_n^2/d$$, where $$L_n$$ are the Lucas numbers and d is a Lucas or Fibonacci number. Filipponi, Hart, and Sanchis [8, 13, 14] analyzed the Zeckendorf representation of numbers of the form $$mF_n$$. Filipponi  determined the Zeckendorf representation of $$m F_n F_{n + k}$$ and $$mL_n L_{n + k}$$ for $$m \in \{1,2,3,4\}$$. Bugeaud  studied the Zeckendorf representation of smooth numbers. The study of Zeckendorf representations has been also approached from a combinatorial point of view [1, 9, 12, 21]. Moreover, generalizations of the Zeckendorf representation to linear recurrences other than the sequence of Fibonacci numbers have been considered [4, 5, 10, 11, 16].

For all integers a and $$m \ge 1$$ with $$\gcd (a, m) = 1$$, let $$(a^{-1} \bmod m)$$ denote the least positive multiplicative inverse of a modulo m, that is, the unique $$b \in \{1, \dots , m\}$$ such that $${ab \equiv 1} \pmod m$$. Prempreesuk, Noppakaew, and Pongsriiam  determined the Zeckendorf representation of $$(2^{-1} \bmod F_n)$$, for every positive integer n that is not divisible by 3. (The condition $$3 \not \mid n$$ is necessary and sufficient to have $$\gcd (2, F_n) = 1$$.) In particular, they showed [17, Theorem 3.2] that

\begin{aligned} (2^{-1}\!\!\! \mod F_n) = {\left\{ \begin{array}{ll} \sum \nolimits _{k \,=\, 0}^{(n - 7) / 2} F_{n - 3k - 2} + F_3 &{} \text { if } n \equiv 1 \mod 3 ;\\ \sum \nolimits _{k \,=\, 0}^{(n - 8) / 2} F_{n - 3k - 2} + F_4 &{} \text { if } n \equiv 2 \mod 3 ; \end{array}\right. } \end{aligned}

for every integer $$n \ge 8$$. We extend their result by determining the Zeckendorf representation of the multiplicative inverse of a modulo $$F_n$$, for every fixed integer $$a \ge 3$$ and every positive integer n with $$\gcd (a, F_n) = 1$$. Precisely, we prove the following result.

### Theorem 1.1

Let $$a \ge 3$$ be an integer. Then there exist integers $$M, n_0, i_0 \ge 1$$ and periodic sequences $$\varvec{z}^{(0)}, \dots , \varvec{z}^{(M - 1)}$$ and $$\varvec{w}^{(1)}, \dots , \varvec{w}^{(i_0)}$$ with values in $$\{0, 1\}$$ such that, for all integers $$n \ge n_0$$ with $$\gcd (a, F_n) = 1$$, the Zeckendorf representation of $$(a^{-1} \bmod F_n)$$ is given by

\begin{aligned} (a^{-1} \bmod F_n) = \sum _{i \,=\, i_0}^{n - 1} z_{n - i}^{(n \bmod M)} F_i + \sum _{i \,=\, 1}^{i_0 - 1} w_n^{(i)} F_i . \end{aligned}

From the proof of Theorem 1.1 it follows that $$M, n_0, i_0$$, $$\varvec{z}^{(0)}, \dots , \varvec{z}^{(M - 1)}$$, and $$\varvec{w}^{(1)}, \dots , \varvec{w}^{(i_0)}$$ can be computed from a (see also Remark 4.1 at the end of the paper).

## Preliminaries on Fibonacci numbers

Let us recall that for every integer $$n \ge 1$$ it holds the Binet formula

\begin{aligned} F_n = \frac{\varphi ^n - \overline{\varphi }^n}{\sqrt{5}} , \end{aligned}

where $$\varphi := (1 + \sqrt{5}) / 2$$ is the Golden ratio and $$\overline{\varphi } := (1 - \sqrt{5}) / 2$$ is its algebraic conjugate. Furthermore, it is well known that for every integer $$m \ge 1$$ the Fibonacci sequence $$(F_n)_{n \ge 1}$$ is (purely) periodic modulo m. Let $$\pi (m)$$ denote its period length, or the so-called Pisano period.

The next lemma gives a formula for the inverse of a modulo $$F_n$$.

### Lemma 2.1

For all integers $$a \ge 1$$ and $$n \ge 3$$ with $$\gcd (a, F_n) = 1$$, we have that

\begin{aligned} (a^{-1} \bmod F_n) = \frac{b F_n + 1}{a} , \end{aligned}

where $$b := (-F_r^{-1} \bmod a)$$ and $$r := (n \bmod \pi (a))$$.

### Proof

Since $$r \equiv n \pmod {\pi (a)}$$, we have that $$F_r \equiv F_n \pmod a$$. In particular, it follows that $$\gcd (a, F_r) = \gcd (a, F_n) = 1$$. Hence, $$F_r$$ is invertible modulo a, and consequently b is well defined. Moreover, we have that

\begin{aligned} bF_n + 1 \equiv -F_r^{-1} F_r + 1 \equiv 0 \pmod a , \end{aligned}

and thus $$c := (bF_n + 1) / a$$ is an integer. On the one hand, we have that

\begin{aligned} ac \equiv b F_n + 1 \equiv 1 \pmod {F_n} . \end{aligned}

On the other hand, since $$b \le a - 1$$ and $$n \ge 3$$, we have that

\begin{aligned} 0 \le c \le \frac{(a - 1) F_n + 1}{a} = F_n - \frac{F_n - 1}{a} < F_n . \end{aligned}

Therefore, we get that $$c = (a^{-1} \bmod F_n)$$, as desired.

## Preliminaries on base-$$\varphi$$ expansion

We need some basic results regarding the so-called base-$$\varphi$$ expansion of real numbers, which was introduced by Bergman  in 1957 (see also ), and which is a particular case of non-integer base expansion (see, e.g., [15, 18]). Let $$\mathfrak {D}$$ be the set of sequences in $$\{0, 1\}$$ that have no two consecutive terms equal to 1, and that are not ultimately equal to the periodic sequence $$0, 1, 0, 1, \dots$$. Then for every $$x \in {[0, 1)}$$ there exists a unique sequence $$\varvec{\delta }(x) = (\delta _i(x))_{i \in \mathbb {N}}$$ in $$\mathfrak {D}$$ such that $$x = \sum _{i = 1}^\infty \delta _i(x) \varphi ^{-i}$$. Precisely, $$\delta _i(x) = \lfloor T^{(i)}(x) \rfloor$$ for every $$i \in \mathbb {N}$$, where $$T^{(i)}$$ denotes the ith iterate of the map $$T : {[0, 1)} \rightarrow {[0, 1)}$$ defined by $$T(\hat{x}) := (\varphi \hat{x} \bmod 1)$$ for every $$\hat{x} \in {[0, 1)}$$. Furthermore, letting $$\mathcal {F} := \mathbb {Q}(\varphi ) \cap {[0,1)}$$, if $$x \in \mathcal {F}$$ then $$\varvec{\delta }(x)$$ is ultimately periodic. In particular, if $$x \in \mathcal {F}$$ is given as $$x = x_1 + x_2 \varphi$$, where $$x_1, x_2 \in \mathbb {Q}$$, then the preperiod and the period of $$\varvec{\delta }(x)$$ can be effectively computed by finding the smallest $$i \in \mathbb {N}$$ such that $$T^{(i)}(x) = T^{(j)}(x)$$ for some $$j \in \mathbb {N}$$ with $$j < i$$. Conversely, for every ultimately periodic sequence $$\varvec{d} = (d_i)_{i \in \mathbb {N}}$$ in $$\mathfrak {D}$$ we have that the number $$x = \sum _{i=1}^\infty d_i \varphi ^{-i}$$ belongs to $$\mathcal {F}$$, and $$x_1, x_2 \in \mathbb {Q}$$ such that $$x = x_1 + x_2 \varphi$$ can be effectively computed in terms of the preperiod and period of $$\varvec{d}$$ by using the formula for the sum of the geometric series. Moreover, in the case that x is a rational number in [0, 1) then $$\varvec{\delta }(x)$$ is purely periodic .

The next lemma collects two easy inequalities for sums involving sequences in $$\mathfrak {D}$$.

### Lemma 3.1

For every sequence $$(d_i)_{i \in \mathbb {N}}$$ in $$\mathfrak {D}$$ and for every $$m \in \mathbb {N} \cup \{\infty \}$$, we have:

1. (1)

$$\sum _{i = 1}^m d_i \varphi ^{-i} \in {[0, 1)}$$ and

2. (2)

$$\sum _{i = 1}^m d_i (-\varphi )^{-i} \in {(-1, \varphi ^{-1})}$$.

### Proof

Since $$(d_i)_{i \in \mathbb {N}}$$ belongs to $$\mathfrak {D}$$, there exists $$k \in \mathbb {N}$$ such that $$d_k = d_{k + 1} = 0$$. Let k be the minimum integer with such property. Then

\begin{aligned} \sum _{i = 1}^\infty d_i \varphi ^{-i}&= \sum _{i = 1}^{k - 1} d_i \varphi ^{-i} + \sum _{i = k + 2}^{\infty } d_i \varphi ^{-i} < \sum _{j = 1}^{\lfloor k / 2\rfloor } \varphi ^{-(2j - 1)} + \sum _{i = k + 2}^{\infty } \varphi ^{-i} \\&= \left( 1 - \varphi ^{-2 \lfloor k / 2 \rfloor }\right) + \varphi ^{-k} \le 1 , \end{aligned}

and ()(1) is proved. Let us prove ()(2). On the one hand, we have

\begin{aligned} \sum _{i = 1}^m d_i (-\varphi )^{-i} \le \sum _{j = 1}^m d_{2j} \varphi ^{-2j} < \sum _{j = 1}^\infty \varphi ^{-2j} = \varphi ^{-1} , \end{aligned}

where the second inequality is strict because $$\mathfrak {D}$$ does not contain sequences that are ultimately equal to $$(0, 1, 0, 1, \dots )$$. On the other hand, similarly, we have

\begin{aligned} \sum _{i = 1}^m d_i (-\varphi )^{-i} \ge -\sum _{j = 1}^m d_{2j - 1} \varphi ^{-(2j - 1)} > -\sum _{j = 1}^\infty \varphi ^{-(2j - 1)} = -1 . \end{aligned}

Thus ()(2) is proved.

The following lemma relates base-$$\varphi$$ expansion and Zeckendorf representation.

### Lemma 3.2

Let N be a positive integer and write $$N = x \varphi ^m / \sqrt{5}$$ for some $$x \in \mathcal {F}$$ and some integer $$m \ge 2$$. Then the Zeckendorf representation of N is given by

\begin{aligned} N = \sum _{i = 1}^{m - 1} \delta _{m - i}(x) F_i . \end{aligned}

Moreover, we have $$\delta _m(x) = 0$$.

### Proof

Let $$R := N - \sum _{i = 1}^{m - 1} \delta _{m - i} (x) F_i$$. We have to prove that $$R = 0$$. Since R is an integer, it suffices to show that $$|R| < 1$$. We have

\begin{aligned} \sqrt{5} N&= x \varphi ^m = \sum _{i = 1}^\infty \delta _i(x) \varphi ^{m - i} = \sum _{i = 1}^m \delta _i(x) \varphi ^{m - i} + \sum _{i = m + 1}^\infty \delta _i(x) \varphi ^{m - i} \\&= \sum _{i = 0}^{m - 1} \delta _{m - i}(x) \varphi ^i + \sum _{i = 1}^\infty \delta _{i + m}(x) \varphi ^{-i} \\&= \sum _{i = 0}^{m - 1} \delta _{m - i}(x) (\varphi ^i - \overline{\varphi }^i) + \sum _{i = 0}^{m - 1} \delta _{m - i}(x) \overline{\varphi }^i + \sum _{i = 1}^\infty \delta _{i + m}(x) \varphi ^{-i} \\&= \sqrt{5} \sum _{i = 1}^{m - 1} \delta _{m - i}(x) F_i + \sum _{i = 0}^{m - 1} \delta _{m - i}(x) (-\varphi )^{-i} + \sum _{i = 1}^\infty \delta _{i + m}(x) \varphi ^{-i} . \end{aligned}

Hence, we get that

\begin{aligned} \sqrt{5} R = \sum _{i = 0}^{m - 1} \delta _{m - i}(x) (-\varphi )^{-i} + \sum _{i = 1}^\infty \delta _{i + m}(x) \varphi ^{-i} . \end{aligned}

For the sake of contradiction, suppose that $$\delta _m(x) = 1$$. Then $$\delta _{m+1}(x) = 0$$ and, by Lemma 3.1, it follows that

\begin{aligned} \sqrt{5} R = 1 + \sum _{i = 1}^{m - 1} \delta _{m - i}(x) (-\varphi )^{-i} + \sum _{i = 2}^\infty \delta _{i + m}(x) \varphi ^{-i} \in (1 - 1 + 0, 1 + \varphi ^{-1} + \varphi ^{-1}) = (0, \sqrt{5}) , \end{aligned}

which is a contradiction, since R is an integer.

Therefore, $$\delta _m(x) = 0$$ and, again by Lemma 3.1, we have

\begin{aligned} \sqrt{5} R = \sum _{i = 1}^{m - 1} \delta _{m - i}(x) (-\varphi )^{-i} + \sum _{i = 1}^\infty \delta _{i + m}(x) \varphi ^{-i} \in (-1 + 0, \varphi ^{-1} + 1) \subseteq (-\sqrt{5}, \sqrt{5}) , \end{aligned}

so that $$|R| < 1$$, as desired.

The next lemma regards the base-$$\varphi$$ expansions of the sum of two numbers.

### Lemma 3.3

Let $$x, y \in {[0, 1)}$$, $$m \in \mathbb {N}$$, and put $$v := x + y \varphi ^{-m}$$. Suppose that there exists $$\lambda \in \mathbb {N}$$ such that $$\lambda + 2 \le m$$ and $$\delta _\lambda (x) = \delta _{\lambda + 1}(x) = 0$$. Then, putting

\begin{aligned} w := \sum _{i = \lambda + 2}^\infty \delta _i(x) \varphi ^{-i} + \sum _{i = m + 1}^\infty \delta _{i - m}(y) \varphi ^{-i} , \end{aligned}

we have that $$v, w \in {[0, 1)}$$ and

\begin{aligned} \delta _i(v) = {\left\{ \begin{array}{ll} \delta _i(x) &{}\text { if } i \le \lambda , \\ \delta _i(w) &{}\text { if } i > \lambda , \end{array}\right. } \end{aligned}
(1)

for every $$i \in \mathbb {N}$$.

### Proof

From Lemma 3.1()(1), we have that

\begin{aligned} 0 \le w< \varphi ^{-(\lambda + 1)} + \varphi ^{-m} < \varphi ^{-(\lambda + 1)} + \varphi ^{-(\lambda + 2)} = \varphi ^{-\lambda } . \end{aligned}

Hence, $$w \in {[0,\varphi ^{-\lambda })} \subseteq {[0, 1)}$$ and so $$w = \sum _{i = \lambda + 1}^\infty \delta _i(w) \varphi ^{-i}$$. Therefore, recalling that $$\delta _{\lambda + 1}(x) = 0$$, we get that

\begin{aligned} v&= x + y\varphi ^{-m} = \sum _{i = 1}^\infty \delta _i(x) \varphi ^{-i} + \sum _{i = 1}^\infty \delta _i(y) \varphi ^{-i-m} = \sum _{i = 1}^\infty \delta _i(x) \varphi ^{-i} + \sum _{i = m + 1}^\infty \delta _{i-m}(y) \varphi ^{-i} \\&= \sum _{i = 1}^{\lambda } \delta _i(x) \varphi ^{-i} + w = \sum _{i = 1}^{\lambda } \delta _i(x)\varphi ^{-i} + \sum _{i = \lambda + 1}^{\infty } \delta _i(w)\varphi ^{-i} , \end{aligned}

which is the base-$$\varphi$$ expansion of v. (Note that $$\delta _\lambda (x) = 0$$.) In particular, by Lemma 3.1()(1), we have that $$v \in {[0, 1)}$$. Thus (1) follows.

## Proof of Theorem 1.1

Fix an integer $$a \ge 3$$. Let us begin by defining $$M, n_0, i_0$$, and $$\varvec{z}^{(0)}, \dots , \varvec{z}^{(M - 1)}$$. Put $$M := \pi (a)$$. For each $$r \in \{0, \dots , M - 1\}$$ with $$\gcd (a, F_r) = 1$$, let $$b_r := (-F_r^{-1} \bmod a)$$, $$x_r := b_r / a$$, and $$\varvec{z}^{(r)} := \varvec{\delta }(x_r)$$. Note that $$x_r \in (0, 1)$$. Since $$x_r$$ is a positive rational number, we have that $$\varvec{z}^{(r)}$$ is a (purely) periodic sequence belonging to $$\mathfrak {D}$$. Let $$\ell$$ be the least common multiple of the period lengths of $$\varvec{z}^{(0)}, \dots , \varvec{z}^{(M - 1)}$$, and put $$i_0 := \ell + 3$$. Finally, let $$n_0 := \max \{i_0 + 1, \lceil \log (2a) / \!\log \varphi \rceil \}$$.

Pick an integer $$n \ge n_0$$ with $$\gcd (a, F_n) = 1$$ and, for the sake of brevity, put $$r := (n \bmod M)$$. From Lemma 2.1 and Binet’s formula (2), we get that

\begin{aligned} (a^{-1} \bmod F_n) = \frac{b_r F_n + 1}{a} = \frac{b_r(\varphi ^n - \overline{\varphi }^n)}{\sqrt{5} a} + \frac{1}{a} = (x_r + y_n \varphi ^{-n}) \frac{\varphi ^n}{\sqrt{5}} , \end{aligned}
(2)

where

\begin{aligned} y_n := \frac{\sqrt{5}}{a} - x_r (-\varphi )^{-n} . \end{aligned}

Since $$n \ge n_0$$, it follows that $$y_n \in (0, 1)$$ and $$x_r + y_n \varphi ^{-n} \in (0, 1)$$. Therefore, from (2) and Lemma 3.2, we get that

\begin{aligned} (a^{-1} \bmod F_n) = \sum _{i \,=\, 1}^{n - 1} \delta _{n - i}(x_r + y_n \varphi ^{-n}) F_i . \end{aligned}

Since $$\varvec{\delta }(x_r)$$ is (purely) periodic and belongs to $$\mathfrak {D}$$, we have that $$\varvec{\delta }(x_r)$$ contains infinitely many pairs of consecutive zeros. Furthermore, since the period length of $$\varvec{\delta }(x_r)$$ is at most $$\ell$$, we have that among every $$\ell +1$$ consecutive terms of $$\varvec{\delta }(x_r)$$ there are two consecutive zero. In particular, there exists $$\lambda = \lambda (r)$$ such that $$n - \ell - 3 \le \lambda \le n - 2$$ and $$\delta _{\lambda }(x_r) = \delta _{\lambda + 1}(x_r) = 0$$. Consequently, by Lemma 3.3, we get that $$\delta _i(x_r + y_n \varphi ^{-n}) = \delta _i(x_r)$$ for each positive integer $$i \le \lambda$$ and, a fortiori, for each positive integer $$i \le n - i_0$$. Therefore, we have that

\begin{aligned} (a^{-1} \bmod F_n)&= \sum _{i \,=\, i_0}^{n - 1} \delta _{n - i}(x_r) F_i + \sum _{i \,=\, 1}^{i_0 - 1} \delta _{n - i}(x_r + y_n \varphi ^{-n}) F_i \\&= \sum _{i \,=\, i_0}^{n - 1} z_{n - i}^{(r)} F_i + \sum _{i \,=\, 1}^{i_0 - 1} w_n^{(i)} F_i , \nonumber \end{aligned}
(3)

where $$\varvec{w}^{(1)}, \cdots , \varvec{w}^{(i_0)}$$ are the sequences defined by $$w_n^{(i)} := \delta _{n - i}(x_r + y_n \varphi ^{-n})$$. Note that, by construction,

\begin{aligned} z_1^{(r)}, z_2^{(r)}, \dots , z_{n - i_0}^{(r)}, w_n^{(i_0-1)}, w_n^{(i_0-2)}, \dots , w_n^{(1)} \end{aligned}

is a string in $$\{0,1\}$$ with no consecutive zeros. Hence, (3) is the Zeckendorf representation of $$(a^{-1} \bmod F_n)$$.

It remains only to prove that $$\varvec{w}^{(1)}, \cdots , \varvec{w}^{(i_0)}$$ are periodic. By (3) and the uniqueness of the Zeckendorf representation, it suffices to prove that

\begin{aligned} R(n) := (a^{-1} \bmod F_n) - \sum _{i \,=\, i_0}^{n - 1} z_{n - i}^{(r)} F_i = \sum _{i \,=\, 1}^{i_0 - 1} w_n^{(i)} F_i \end{aligned}
(4)

is a periodic function of n. From the last equality in (4), we have that $$0 \le R(n) < \sum _{i \,=\, 1}^{i_0 - 1} F_i$$. (Actually, one can prove that $$0 \le R(n) < F_{i_0}$$, but this is not necessary for our proof.) Fix a prime number $$p > \max \{a, \sum _{i \,=\, 1}^{i_0 - 1} F_i\}$$. It suffices to prove that R(n) is periodic modulo p. Recalling that $$(a^{-1} \bmod F_n) = (b_r F_n + 1) / a$$ and that the sequence of Fibonacci numbers is periodic modulo p, it follows that $$(a^{-1} \bmod F_n)$$ is periodic modulo p. Hence, it suffices to prove that $$R^\prime (n) := \sum _{i = i_0}^{n - 1} z_{n - i}^{(r)} F_i$$ is periodic modulo p. Using that $$\varvec{z}^{(r)}$$ has period length dividing $$\ell$$, we get that

\begin{aligned} R^\prime (n + \ell M) - R^\prime (n)&= \sum _{i \,=\, i_0}^{n + \ell M - 1} z_{n + \ell M - i}^{((n + \ell M) \bmod M)} F_i - \sum _{i = i_0}^{n - 1} z_{n - i}^{(r)} F_i \\&= \sum _{i \,=\, i_0}^{n + \ell M - 1} z_{n + \ell M - i}^{(r)} F_i - \sum _{i \,=\, i_0}^{n - 1} z_{n - i}^{(r)} F_i \\&= \sum _{i \,=\, n}^{n + \ell M - 1} z_{n + \ell M - i}^{(r)} F_i + \sum _{i \,=\, i_0}^{n - 1} (z_{n + \ell M - i}^{(r)} - z_{n - i}^{(r)}) F_i \\&= \sum _{j \,=\, 1}^{\ell M} z_{j}^{(r)} F_{n + \ell M - j} , \end{aligned}

which is a linear combination of sequences that are periodic modulo p. Hence $$R^\prime (n)$$ is periodic modulo p. The proof is complete.

### Remark 4.1

The proof of Theorem 1.1 provides a way to compute the positive integers $$M, i_0, n_0$$ and the periods of the periodic sequences $$\varvec{z}^{(0)}, \dots , \varvec{z}^{(M - 1)}$$ and $$\varvec{w}^{(1)}, \dots , \varvec{w}^{(i_0)}$$. Indeed, going through the proof, we have that: $$M = \pi (a)$$ is the Pisano period of a, which can be computed in an obvious way; $$\varvec{z}^{(r)} = \varvec{\delta }\big ((-F_r^{-1}\!\!\! \mod a) / a\big )$$ and so the period of $$\varvec{z}^{(r)}$$ can be computed as explained at the beginning of Section 3; $$i_0$$ and $$n_0$$ have simple formulas in terms of $$\ell$$, which is the least common multiple of the period lengths of $$\varvec{z}^{(0)}, \dots , \varvec{z}^{(M - 1)}$$. Finally, the periods of $$\varvec{w}^{(1)}, \dots , \varvec{w}^{(i_0)}$$ can be computed from (4) and the fact that R(n) is periodic with period length at most $$\pi (p)^2 \ell M$$, which follows from the arguments after (4). However, note that proceeding in this way might be impractical, since $$\ell$$ might be exponential in M, and thus p might be double exponential in M; making the search for the periods of $$\varvec{w}^{(1)}, \dots , \varvec{w}^{(i_0)}$$ extremely long.