1 Introduction

In 1940, Mahler [11] gave the first idea for introducing continued fractions in the field of p-adic numbers \(\mathbb Q_p\). Starting from this, several authors studied the problem of defining an algorithm for expanding elements of \(\mathbb Q_p\) in continued fractions. The most notable results were provided by Browkin [4], Ruban [14] and Schneider [15] who defined different p-adic continued fractions algorithms with the aim of obtaining the same good properties that hold in the real case. However, all these algorithms fail in the attempt of characterizing quadratic irrationals by periodic continued fractions, as in the case of \(\mathbb R\). The study of the periodicity of these algorithms have been deepened by several authors. Schneider’s algorithm is not periodic for all quadratic irrationals, but there is an effective criterion to determine when this happens (see [8, 16, 17]). Ooto [13] proved that an analogue of Lagrange’s Theorem does not hold for Ruban’s continued fractions and Capuano et al. [7] gave an effective condition to check the periodicity. Moreover, Ruban’s and Schneider’s algorithms provide finite or periodic expansion for rationals. Browkin’s algorithm is of particular interest since it always gives finite representations for rational numbers, but it is not known if an analogue of the Lagrange’s Theorem holds. In [2, 3], the authors proved some results about the periodicity of this algorithm and Capuano et al. [6] gave some necessary and sufficient conditions for periodicity, but such conditions do not allow to prove that an analogue of Lagrange’s Theorem does not hold. From experimental results, it seems very unlikely that Browkin’s algorithm provides periodic expansion for any quadratic irrational. For this reason, in 2000, Browkin himself defined a new algorithm [5] and it has been proved in [1] that also this second algorithm produces a finite continued fraction for rational numbers. Browkin’s second algorithm works better on quadratic irrationals, but also in this case they do not always present periodic expansions in continued fractions. The periodicity of this algorithm has been investigated in [12]. Further studies on p-adic continued fractions can be found in [9, 10, 18, 19]. Thus, it is worth to study the definition of new algorithms for p-adic continued fractions.

In this paper, we give a sufficient condition on the partial quotients of a p-adic continued fractions in order to achieve the convergence in \(\mathbb {Q}_p\). In particular, we study a condition that allows to extend the idea of Browkin in [5], giving space to several possible new definitions of p-adic continued fractions. Exploiting this condition, we then propose a new p-adic continued fraction algorithm that is a natural generalization of the construction performed in [5] for the second algorithm of Browkin. Moreover, we also prove that this new algorithm terminates in a finite number of steps on each \(\alpha \in \mathbb {Q}\).

2 Preliminaries

Let us denote with \(v_p(\cdot )\) and \(|\cdot |_p\), respectively, the p-adic valuation and the p-adic absolute value over \(\mathbb {Q}\), where p is an odd prime. The Euclidean norm will be denoted as usual by \(|\cdot |\). We denote a continued fraction of a value \(\alpha \) with the usual notation as

$$\begin{aligned} \alpha = b_0 + \frac{1}{b_1 + \frac{1}{b_2 + \frac{1}{\ddots }}} = [b_0, b_1, b_2, \ldots ]. \end{aligned}$$

Moreover, we call \(\frac{A_n}{B_n}\), for all \(n\in \mathbb {N}\), the convergents of the continued fraction, that may be defined recursively by using the well-known formulas

$$\begin{aligned} {\left\{ \begin{array}{ll} A_0=b_0,\\ A_1=b_1b_0+1,\\ A_n=b_nA_{n-1}+A_{n-2} \text { for } n \ge 2, \end{array}\right. } {\left\{ \begin{array}{ll} B_0=1,\\ B_1=b_1,\\ B_n=b_nB_{n-1}+B_{n-2} \text { for } n \ge 2. \end{array}\right. } \end{aligned}$$

The first important requirement when designing an algorithm for p-adic continued fractions is that all the expansions converge to a p-adic number, that is

$$\begin{aligned} \lim \limits _{n\rightarrow +\infty } \frac{A_n}{B_n}=\alpha \in \mathbb {Q}_p. \end{aligned}$$

The first algorithm proposed by Browkin in [4] works as follows. Starting from an input \(\alpha _0\in \mathbb {Q}_p\) then the partial quotients of the p-adic continued fraction are evaluated by

$$\begin{aligned} {\left\{ \begin{array}{ll} b_n=s(\alpha _n)\\ \alpha _{n+1}=\frac{1}{\alpha _n-b_n}, \end{array}\right. } \quad n \ge 0 \end{aligned}$$
(1)

where \(s:\mathbb {Q}_p\rightarrow \mathbb {Q}\) is defined by

$$\begin{aligned} s(\alpha )=\sum \limits _{n=-r}^{0} a_n p^n\in \mathbb {Q}, \end{aligned}$$

for a p-adic number \(\alpha =\sum \limits _{n=-r}^{+\infty } a_np^n\in \mathbb {Q}_p\), with \(r\in \mathbb {Z}\) and \(a_n\in \{-\frac{p-1}{2},\ldots ,\frac{p-1}{2}\}\). In this algorithm, the function s plays the same role of the floor function in the classical algorithm of continued fractions in \(\mathbb R\). Ruban’s algorithm [14] employs the same function s, with the only difference that the representatives are taken in \(\{0,\ldots , p-1 \}\). More than 20 years later, Browkin defines another algorithm in [5], where starting from \(\alpha _0\in \mathbb {Q}_p\), the partial quotients \(b_n\), for \(n \ge 0\), are evaluated by

$$\begin{aligned} {\left\{ \begin{array}{ll} b_n=s(\alpha _n) \ \ \ \ \ {} &{} if \ n \ even \\ b_n=t(\alpha _n) &{} if \ n \ odd \ and \ v_p(\alpha _n-t(\alpha _n))= 0\\ b_n=t(\alpha _n)-sign(t(\alpha _n)) &{} if \ n \ odd \ and \ v_p(\alpha _n-t(\alpha _n))\ne 0\\ \alpha _{n+1}=\frac{1}{\alpha _n-b_n}, \end{array}\right. } \end{aligned}$$
(2)

where \(t:\mathbb {Q}_p\rightarrow \mathbb {Q}\) is another function defined for any p-adic value \(\alpha =\sum \limits _{n=-r}^{+\infty } a_np^n\) as

$$\begin{aligned} t(\alpha )=\sum \limits _{n=-r}^{-1}a_np^n, \end{aligned}$$

with \(r\in \mathbb {Z}\) and \(a_n\in \{-\frac{p-1}{2},\ldots ,\frac{p-1}{2}\}\). In the following we will refer to (1) and (2) respectively as Browkin I and Browkin II.

The convergence in \(\mathbb {Q}_p\) of the continued fractions generated by Browkin I is based on the following lemma.

Lemma 1

[4, Lemma 1] Let an infinite sequence \(b_0,b_1,\ldots \in \mathbb {Z}[\frac{1}{p}]\) such that \(v_p(b_{n})<0\), for all \(n \ge 1\). Then the continued fraction \([b_0,b_1,\ldots ]\) is convergent to a p-adic number.

In fact, the partial quotients \(b_n\) arising from Browkin I, for \(n\ge 1\), all have negative valuations.

For what concerns Browkin II, the p-adic convergence relies on the following lemma.

Lemma 2

[5, Lemma 1] Let an infinite sequence \(b_0,b_1,\ldots \in \mathbb {Z}[\frac{1}{p}]\) such that, for all \(n\in \mathbb {N}\),

$$\begin{aligned} {\left\{ \begin{array}{ll} v_p(b_{2n})=0\\ v_p(b_{2n+1})<0. \end{array}\right. } \end{aligned}$$
(3)

Then the continued fraction \([b_0,b_1,\ldots ]\) is convergent to a p-adic number.

Remark 3

The proofs of Lemmas 1 and 2 exploit the strict decrease of the sequence of valuations \(v_p(B_n{B_{n+1}})\). Moreover, requiring the sequence \(v_p(B_{n}B_{n+1})\) strictly decreasing is equivalent to ask that \(v_p(B_{n+1})<v_p(B_{n-1})\) for all \(n\ge 1\). Thus, the divergence of the sequence of valuations implies the convergence of the correspondent p-adic continued fraction. Indeed, in this way we have that

$$\begin{aligned} \lim _{n \rightarrow \infty } v_p\left( \frac{A_{n+1}}{B_{n+1}} - \frac{A_n}{B_n} \right) = \lim _{n \rightarrow \infty } - v_p(B_nB_{n+1}) = +\infty , \end{aligned}$$

and

$$\begin{aligned} \left| \frac{A_{m}}{B_{m}}-\frac{A_n}{B_n}\right| _p=\left| \frac{A_{n+1}}{B_{n+1}}-\frac{A_n}{B_n}\right| _p=\left| \frac{(-1)^n}{B_{n}B_{n+1}}\right| _p=p^{v_p(B_nB_{n+1})}, \end{aligned}$$

proving that \(\left\{ \frac{A_n}{B_n} \right\} _{n\in \mathbb {N}}\) is a Cauchy sequence and therefore convergent in \(\mathbb Q_p\).

3 Convergence of p-adic continued fractions

The reduction of the number of partial quotients having negative valuations shows better properties in terms of the periods of quadratic irrationals, as pointed out in [5]. Therefore a promising approach for the definition of a new algorithm should be a further modification of Browkin II: we may define a “3-steps”-algorithm that generates the partial quotients such that, for all \(n \in \mathbb {N}\),

$$\begin{aligned} {\left\{ \begin{array}{ll} v_p(b_{3n+1})<0\\ v_p(b_{3n+2})=0\\ v_p(b_{3n+3})=0. \end{array}\right. } \end{aligned}$$
(4)

Such a construction turns out to be more complex than the previous two algorithms defined by Browkin. In the following example we show that a sequence having these constraints does not converge without a stronger hypothesis. In particular, for every prime p, we may construct a suitable continued fraction that does not converge to any p-adic number.

Example 4

Let p be an odd prime. We are going to show that there exists a sequence \(b_0,b_1,\ldots \in \mathbb {Q}_p\) with, for all \(n\in \mathbb {N}\),

$$\begin{aligned}{\left\{ \begin{array}{ll} v_p(b_{3n+1})<0\\ v_p(b_{3n+2})=0\\ v_p(b_{3n+3})=0, \end{array}\right. } \end{aligned}$$

such that the sequence \(v_p(B_nB_{n+1})\) does not diverge to \(-\infty \). Let us define \(b_{1}=\frac{1}{p}\). The first denominators of the convergents are

$$\begin{aligned} B_0&=1,\\ B_1&=b_1=\frac{1}{p},\\ B_2&=b_2B_1+B_0=\frac{b_2+p}{p},\\ B_3&=b_3B_2+B_1=\frac{(b_3b_2+1)+b_3p}{p}. \end{aligned}$$

Their valuations are

$$\begin{aligned} v_p(B_0)&=v_p(1)=0,\\ v_p(B_1)&=v_p\Big (\frac{1}{p}\Big )=-1,\\ v_p(B_2)&=v_p\Big (\frac{b_2+p}{p}\Big )=-1,\\ v_p(B_3)&=v_p\Big (\frac{(b_3b_2+1)+b_3p}{p}\Big ). \end{aligned}$$

Let us choose suitable \(b_2\) and \(b_3\) such that \(b_3b_2+1=p\) (for example, \(b_2=2\) and \(b_3=\frac{p-1}{2}\)). Then

$$\begin{aligned} v_p(B_3)=v_p\Big (\frac{b_3p+p}{p}\Big )=v_p(b_3+1)\ge 0. \end{aligned}$$

At this point, for a generic \(n\in \mathbb {N}\) for which

$$\begin{aligned} v_p(B_{3n+1})=-1, \ v_p(B_{3n+2})=-1, \ v_p(B_{3n+3})\ge 0, \end{aligned}$$

we are going to show that there exists a choice for the partial quotients such that

$$\begin{aligned} v_p(B_{3(n+1)+1})=-1, \ v_p(B_{3(n+1)+2})=-1, \ v_p(B_{3(n+1)+3})\ge 0. \end{aligned}$$

We can write

$$\begin{aligned} B_{3n+1}&=\frac{a_1}{p}, \ {}&with \ v_p(a_1)&=0,\\ B_{3n+2}&=\frac{a_2}{p}, \ {}&with \ v_p(a_2)&=0,\\ B_{3n+3}&=a_3, \ {}&with \ v_p(a_3)&\ge 0. \end{aligned}$$

We have two cases:

  • In the case that \(v_p(a_3+a_2)=0\), we choose \(b_{3n+4}=\frac{1}{p}\). Therefore,

    $$\begin{aligned} B_{3n+4}=b_{3n+4}B_{3n+3}+B_{3n+2}=\frac{a_3+a_2}{p}. \end{aligned}$$

    Its valuation is

    $$\begin{aligned} v_p(B_{3n+4})=v_p(a_3+a_2)-v_p(p)=-1, \end{aligned}$$

    so that we can write \(B_{3n+4}=\frac{a_4}{p}\), with \(v_p(a_4)=0\). Subsequently,

    $$\begin{aligned} B_{3n+5}=b_{3n+5}B_{3n+4}+B_{3n+3}=b_{3n+5}\frac{a_4}{p}+a_3=\frac{b_{3n+5}a_4+a_3p}{p}, \end{aligned}$$

    with \(v_p(b_{3n+5})=0\), so that \(v_p(B_{3n+5})=-1\). It means that \(B_{3n+5}=\frac{a_5}{p}\), with \(v_p(a_5)=0\). At the following step,

    $$\begin{aligned} B_{3n+6}=b_{3n+6}B_{3n+5}+B_{3n+4}=\frac{b_{3n+6}a_5+a_4}{p}. \end{aligned}$$

    Notice that \(a_4\) and \(a_5\) are arbitrary elements that are nonzero modulo p and we can choose a suitable \(b_{3n+6}\) such that

    $$\begin{aligned} b_{3n+6}a_5+a_4\equiv 0 \bmod p. \end{aligned}$$

    We obtain that p divides \(b_{3n+6}a_5+a_4\) and so \(v_p(B_{3n+6})\ge 0\). In this case we have obtained that, starting from

    $$\begin{aligned} v_p(B_{3n+1})=-1, \ v_p(B_{3n+2})=-1, \ v_p(B_{3n+3})\ge 0, \end{aligned}$$

    then

    $$\begin{aligned} v_p(B_{3(n+1)+1})=-1, \ v_p(B_{3(n+1)+2})=-1, \ v_p(B_{3(n+1)+3})\ge 0. \end{aligned}$$
  • Let us examine also the case \(v_p(a_3+a_2)>0\). Here we choose \(b_{3n+4}=\frac{2}{p}\). Since \(v_p(a_2)=0\) and \(v_p(a_3+a_2)>0\), necessarily also \(v_p(a_3)=0\). The next denominator is

    $$\begin{aligned} B_{3n+4}=b_{3n+4}B_{3n+3}+B_{3n+2}=\frac{2a_3+a_2}{p}. \end{aligned}$$

    Notice that since p divides \(a_3+a_2\) but does not divide \(a_3\), it can not divide \(2a_3+a_2\). In this way \(v_p(2a_3+a_2)=0\) and

    $$\begin{aligned} v_p(B_{3n+4})=v_p(2a_3+a_2)-v_p(p)=-1. \end{aligned}$$

    Then we get

    $$\begin{aligned} v_p(B_{3n+5})=v_p(b_{3n+5}B_{3n+4}+B_{3n+3})=-1, \end{aligned}$$

    where \(v_p(b_{3n+5})=0\), and so we can write

    $$\begin{aligned} B_{3n+4}&=\frac{a_4}{p}, \ {}&with \ v_p(a_4)&=0,\\ B_{3n+5}&=\frac{a_5}{p}, \ {}&with \ v_p(a_5)&=0. \end{aligned}$$

    At the next step we have

    $$\begin{aligned} B_{3n+6}=b_{3n+6}B_{3n+5}+B_{3n+4}=\frac{b_{3n+6}a_5+a_4}{p}. \end{aligned}$$

    As before, we choose \(b_{3n+6}\) such

    $$\begin{aligned} b_{3n+6}a_5+a_4\equiv 0 \bmod p. \end{aligned}$$

    In this way we get \(v_p(B_{3n+6})\ge 0\). Hence, also in this second case we have obtained that

    $$\begin{aligned} v_p(B_{3(n+1)+1})=-1, \ v_p(B_{3(n+1)+2})=-1, \ v_p(B_{3(n+1)+3})\ge 0. \end{aligned}$$

We have just constructed a sequence of denominators \(B_n\) such that the sequence of valuations \(v_p(B_{n}B_{n+1})=v_p(B_{n})+v_p(B_{n+1})\) can not diverge to \(-\infty \). In fact, in particular, \(v_p(B_n)\ge -1\) for all \(n\in \mathbb {N}\) and the p-adic continued fraction is not convergent.

Starting from the observations of the last example, we would like to characterize the strict decrease of the sequence \(v_p(B_nB_{n+1})\) in general. From Remark 3, it is sufficient to investigate the condition \(v_p(B_{n+1})<v_p(B_{n-1})\) for all \(n\ge 1\).

In the following, \(b_0,b_1,\ldots \) are elements of \(\mathbb {Q}_p\) such that \(v_p(b_n)\le 0\) for all \(n\in \mathbb {N}\). In fact, as we are going to see in the next results, Browkin’s hypothesis of \(b_n\in \mathbb {Z}[\frac{1}{p}]\) for all \(n\in \mathbb {N}\), seen in Lemmas 1 and 2, is not needed.

Lemma 5

For all \(n\ge 1\), if \(v_p(B_{n+1})<v_p(B_{n-1})\), then

$$\begin{aligned} v_p(B_{n+1})\le v_p(B_n). \end{aligned}$$

Proof

Let us recall that

$$\begin{aligned} v_p(B_{n+1})=v_p(b_{n+1}B_n+B_{n-1})\ge \min \{v_p(b_{n+1}B_n),v_p(B_{n-1}) \}, \end{aligned}$$

with the equality for \(v_p(b_{n+1}B_n)\ne v_p(B_{n-1})\).

If \(v_p(b_{n+1}B_n)< v_p(B_{n-1})\), then

$$\begin{aligned} v_p(B_{n+1})=v_p(b_{n+1}B_n)=v_p(b_{n+1})+v_p(B_n)\le v_p(B_n), \end{aligned}$$

since \(v_p(b_{n+1})\le 0\). Instead, if \(v_p(b_{n+1}B_n)\ge v_p(B_{n-1})\),

$$\begin{aligned} v_p(B_{n+1})\ge \min \{v_p(b_{n+1}B_n),v_p(B_{n-1})\}= v_p(B_{n-1}), \end{aligned}$$

but it is a contradiction with the hypothesis of \(v_p(B_{n+1})<v_p(B_{n-1})\), hence this second case can not occur. \(\square \)

On the other hand it is also possible to prove the following equivalence.

Lemma 6

For all \(n\ge 1\), \(v_p(B_{n+1})<v_p(B_{n-1})\) if and only if

$$\begin{aligned} v_p(b_{n+1}B_{n})<v_p(B_{n-1}). \end{aligned}$$

Proof

If \(v_p(B_{n+1})<v_p(B_{n-1})\) and \(v_p(b_{n+1}B_{n})\ge v_p(B_{n-1})\), then

$$\begin{aligned} v_p(B_{n+1})\ge \min \{v_p(b_{n+1}B_{n}),v_p(B_{n-1})\}=v_p(B_{n-1}), \end{aligned}$$

but this contradicts the hypothesis.

Conversely, if \(v_p(b_{n+1}B_{n})<v_p(B_{n-1})\), then

$$\begin{aligned} v_p(B_{n+1})=v_p(b_{n+1}B_{n})<v_p(B_{n-1}), \end{aligned}$$

and the claim is proved. \(\square \)

Using the results obtained above, we may prove the following theorem on the characterization of the strict decrease of the sequence \(v_p(B_nB_{n+1})\).

Theorem 7

The following conditions are equivalent:

  1. (i)

    \(v_p(b_{n+1}B_{n})<v_p(B_{n-1})\), for all \(n\ge 1\),

  2. (ii)

    \(v_p(b_nb_{n+1})<0\), for all \(n\ge 1\).

Proof

\(i)\Rightarrow ii)\)

Let us suppose that \(v_p(b_{n+1}B_{n})<v_p(B_{n-1})\) for all \(n\ge 1\).

If \(v_p(b_{n+1})<0\), then \(v_p(b_{n+1}b_{n})=v_p(b_{n+1})+v_p(b_{n})<0\) and the claim is proved. Therefore, let us assume \(v_p(b_{n+1})=0\) and we prove that \(v_p(b_{n})<0\). Since \(v_p(b_{n+1})=0\) and

$$\begin{aligned} v_p(b_{n+1}B_{n})<v_p(B_{n-1}), \end{aligned}$$

then \(v_p(B_{n})<v_p(B_{n-1})\). The latter means that:

$$\begin{aligned} v_p(B_{n})=v_p(b_{n}B_{n-1}+B_{n-2})<v_p(B_{n-1}). \end{aligned}$$

Moreover, let us recall that, in general,

$$\begin{aligned} v_p(B_n)\ge \min \{v_p(b_{n}B_{n-1}),v_p(B_{n-2})\}. \end{aligned}$$

If \(v_p(B_{n-2})\le v_p(b_{n}B_{n-1})\), then we would have \(v_p(B_n)\ge v_p(B_{n-2})\), which is a contradiction with the characterization of i) given by Lemma 6. Then \(v_p(B_{n-2})>v_p(b_{n}B_{n-1})\) and it follows that \(v_p(B_n)=v_p(b_{n}B_{n-1})\). Hence,

$$\begin{aligned} v_p(B_n)=v_p(b_{n}B_{n-1})=v_p(b_{n}) +v_p(B_{n-1})<v_p(B_{n-1}), \end{aligned}$$

where the last inequality implies \(v_p(b_{n})<0\) and this concludes the proof.

\(ii)\Rightarrow i)\)

Conversely, let us suppose that \(v_p(b_nb_{n+1})<0\) for all \(n\ge 1\). We prove the claim by induction on n.

Base step

By hypothesis, we have that \(v_p(b_1b_2)<0\) and \(v_p(b_2b_3)<0\). Hence, for \(n=1\) and \(n=2\), we have that:

$$\begin{aligned} v_p(b_2B_1)&=v_p(b_2b_1)<0=v(1)=v(B_0),\\ v_p(b_3B_2)&=v_p(b_3b_2b_1+b_3)=v_p(b_3b_2b_1)=v_p(b_3b_2)+v_p(b_1)\\&<v_p(b_1)=v_p(B_1). \end{aligned}$$

Induction step

Let us suppose that the thesis is true until a step \(n\ge 2\) and we show it for \(n+1\). From \(v_p(b_{n+2}b_{n+1})<0\) we get that either \(v_p(b_{n+2})<0\) or \(v_p(b_{n+1})<0\) (or both).

  • Case \(v_p(b_{n+2})<0\):

    In this case, using inductive hypothesis and Lemma 5 we get that \(v_p(B_{n+1})\le v_p(B_n)\), hence:

    $$\begin{aligned}v_p(b_{n+2}B_{n+1})=v_p(b_{n+2})+v_p(B_{n+1})<v_p(B_{n+1})\le v_p(B_n).\end{aligned}$$
  • Case \(v_p(b_{n+1})<0\): where the last inequality implies In this case we have

    $$\begin{aligned} b_{n+2}B_{n+1}=b_{n+2}\left( b_{n+1}B_{n} + B_{n-1} \right) , \end{aligned}$$

    therefore

    $$\begin{aligned} v_p \left( b_{n+2}B_{n+1} \right) \le v_p\left( b_{n+1}B_{n} + B_{n-1} \right) . \end{aligned}$$

    The inductive hypothesis ensures that \(v_p\left( b_{n+1}B_{n} \right) < v_p(B_{n-1})\), so

    $$\begin{aligned} v_p \left( b_{n+2}B_{n+1} \right) \le v_p\left( b_{n+1}B_{n} \right) =v_p\left( b_{n+1}\right) +v_p\left( B_{n} \right) < v_p(B_n) \end{aligned}$$

    and this concludes the proof.

\(\square \)

We easily obtain the following corollary, fully characterizing the strict decrease of the sequence of denominators.

Corollary 8

The sequence \(\{v_p(B_nB_{n+1})\}_{n\in \mathbb {N}}\) is strictly decreasing if and only if \(v_p(b_nb_{n+1})<0\) for all \(n\in \mathbb {N}\).

In other words, we have proved that the definition of two consecutive partial quotients with zero valuation makes us lose the strict decrease of the valuation. Moreover, the sufficiency of this condition means that every possible definition in this range works. It would be interesting to study some algorithms that satisfy this hypothesis, different from Browkin I and Browkin II. For example, it is possible to define 2 negative partial quotients every 3 steps or partial quotients that are not in \(\mathbb {Z}[\frac{1}{p}]\), as long as the condition, \(v_p(b_nb_{n+1})<0\) for all \(n\in \mathbb {N}\), is satisfied.

4 Design of a new algorithm

In Example 4 we have showed that an algorithm generating the partial quotients as in (4) never assures the p-adic convergence of the continued fraction. Moreover, we have characterized the strict decrease of the sequence \(v_p(B_nB_{n+1})\).

However, for the negative divergence of this sequence, we do not need it to be strictly decreasing. So we may wonder in which cases it diverges although it is not strictly decreasing.

What we are going to see here is that adding one additional constraint on the two partial quotients having null valuation it is possible to avoid the growth of the valuation of the denominators \(B_n\). In this way we succeed to obtain the convergence of a p-adic continued fraction with only one partial quotient with negative valuation each three steps, as defined in (4).

Theorem 9

Let \(b_0,b_1,\ldots \in \mathbb {Q}_p\) such that, for all \(n\in \mathbb {N}\):

$$\begin{aligned}{\left\{ \begin{array}{ll} v_p(b_{3n+1})<0\\ v_p(b_{3n+2})=0\\ v_p(b_{3n+3})=0. \end{array}\right. }\end{aligned}$$

If \(v_p(b_{3n+3}b_{3n+2}+1)=0\) for all \(n \in \mathbb {N}\), then,

$$\begin{aligned} v_p(B_{3n-2})=v_p(B_{3n-1})=v_p(B_{3n})>v_p(B_{3n+1}). \end{aligned}$$

Proof

Let us prove the claim by induction on n.

Base step

$$\begin{aligned} v_p(B_0)&=v_p(1)=0,\\ v_p(B_{1})&=b_1<0,\\ v_p(B_2)&=v_p(b_2b_1+1)=v_p(b_2)+v_p(b_1)=v_p(b_1)=v_p(B_1),\\ v_p(B_3)&=v_p(b_3B_2+B_1)=v_p((b_3b_2+1)B_1+b_3B_0)\\&=v_p((b_3b_2+1)B_1)=v_p(B_1)=v_p(B_2),\\ v_p(B_4)&=v_p(b_4B_3+B_2)=v_p(b_4)+v_p(B_3)<v_p(B_3)\\&=v_p(B_1)=v_p(B_2), \end{aligned}$$

where we employed that \(v_p(b_4)<0\) and \(v_p(b_3b_2+1)=0\).

Induction step

Let us suppose that:

$$\begin{aligned} v_p(B_{3n-2})=v_p(B_{3n-1})=v_p(B_{3n})>v_p(B_{3n+1}). \end{aligned}$$

In fact, the valuation of \(B_{3n+1}\) is:

$$\begin{aligned} v_p(B_{3n+1})=v_p(b_{3n+1}B_{3n}+B_{3n-1})=v_p(b_{3n+1})+v_p(B_{3n}) < v_p(B_{3n}), \end{aligned}$$

since, by induction hypothesis, \(v_p(B_{3n})=v_p(B_{3n-1})\) and \(v_p(b_{3n+1})<0\).

Recalling that \(v_p(b_{3n+4})<0\) and \(v_p(b_{3n+3}b_{3n+2}+1)=0\), at the following steps we obtain:

$$\begin{aligned} v_p(B_{3n+2})&=v_p(b_{3n+2}B_{3n+1}+B_{3n})=v_p(b_{3n+2})+v_p(B_{3n+1})\\&=v_p(B_{3n+1})<v_p(B_{3n}),\\ v_p(B_{3n+3})&=v_p(b_{3n+3}B_{3n+2}+B_{3n+1})\\&=v_p((b_{3n+3}b_{3n+2}+1)B_{3n+1}+b_{3n+3}B_{3n})\\&=v_p((b_{3n+3}b_{3n+2}+1)B_{3n+1})=v_p(B_{3n+1})\\ {}&=v_p(B_{3n+2})<v_p(B_{3n}),\\ v_p(B_{3n+4})&=v_p(b_{3n+4}B_{3n+3}+B_{3n+2})=v_p(b_{3n+4})+v_p(B_{3n+3})\\&<v_p(B_{3n+3})=v_p(B_{3n+1})=v_p(B_{3n+2}). \end{aligned}$$

Hence, we have obtained that

$$\begin{aligned} v_p(B_{3n+4})<v_p(B_{3n+3})=v_p(B_{3n+2})=v_p(B_{3n+1})<v_p(B_{3n}), \end{aligned}$$

and this proves the claim. \(\square \)

Theorem 9 easily leads to the following corollary, achieving the convergence of a p-adic continued fraction generating the partial quotients as in (4).

Corollary 10

Let \(b_0,b_1,\ldots \) as in Theorem 9. Then the continued fraction \([b_0,b_1,\ldots ]\) is convergent to a p-adic number.

Proof

We know from Remark 3 that the continued fraction \([b_0,b_1,\ldots ]\) converges to a p-adic number if and only if

$$\begin{aligned} \lim \limits _{n\rightarrow +\infty } v_p(B_nB_{n+1})= -\infty . \end{aligned}$$

Notice that, for all \(n\in \mathbb {N}\),

$$\begin{aligned} v_p(B_{3n}B_{3n+1})>v_p(B_{3n+1}B_{3n+2}), \end{aligned}$$

since \(v_p(B_{3n+1})<v_p(B_{3n})\) and \(v_p(B_{3n+1})=v_p(B_{3n+2})\). Then

$$\begin{aligned} v_p(B_{3n+1}B_{3n+2})=v_p(B_{3n+2}B_{3n+3}), \end{aligned}$$

since all the three valuations are equal. Moreover,

$$\begin{aligned} v_p(B_{3n+2}B_{3n+3})>v_p(B_{3n+3}B_{3n+4}), \end{aligned}$$

since \(v_p(B_{3n+4})<v_p(B_{3n+3})\) and \(v_p(B_{3n+3})=v_p(B_{3n+2})\). So, the sequence \(v_p(B_nB_{n+1})\) is decreasing and divergent. \(\square \)

5 Some new algorithms

Starting from Theorem 9 and Corollary 10, we propose some new algorithms. We use three different functions. For

$$\begin{aligned} a=\sum \limits _{n=-r}^{+\infty }a_np^n\in \mathbb {Q}_p, \ \ \ \ a_n\in \Big \{ 0, \pm 1,\pm 2,\ldots ,\pm \frac{p-1}{2}\Big \}, \end{aligned}$$

the first two functions are the same s and t of Browkin II, that are

$$\begin{aligned} s(a)=\sum \limits _{n=-r}^{0}a_np^n, \ \ \ t(a)=\sum \limits _{n=-r}^{-1}a_np^n, \end{aligned}$$

and then the third is:

$$\begin{aligned} u(a)={\left\{ \begin{array}{ll} +1 \ \ &{}if \ a_0\in \Big \{+2,\ldots ,\dfrac{p-1}{2}\Big \}\cup \{-1\}\\ -1 &{}if \ a_0\in \Big \{-\dfrac{p-1}{2},\ldots ,-2\Big \}\cup \{+1\}\\ 0 \ \ {} &{}if \ a_0=0. \end{array}\right. } \end{aligned}$$

We can now design the form of two new algorithms.

Definition 11

(First new algorithm) On input \(\alpha _0=\alpha \), for \(n\ge 0\), our first new algorithm works as follows:

$$\begin{aligned} {\left\{ \begin{array}{ll} b_n=s(\alpha _n) \ \ \ \ \ {} &{}if \ n \equiv 0\bmod 3\\ b_n=t(\alpha _n) &{}if \ n \equiv 1 \bmod 3 \ and \ v_p(\alpha _n-t(\alpha _n))= 0\\ b_n=t(\alpha _n)-sign(t(\alpha _n)) &{} if \ n \equiv 1 \bmod 3 \ and \ v_p(\alpha _n-t(\alpha _n))\ne 0\\ b_n=u(\alpha _n) &{} if \ n \equiv 2 \bmod 3\\ \alpha _{n+1}=\frac{1}{\alpha _n-b_n}. \end{array}\right. } \end{aligned}$$

Definition 12

(Second new algorithm) On input \(\alpha _0=\alpha \), for \(n\ge 0\), our second new algorithm works as follows:

$$\begin{aligned}{\left\{ \begin{array}{ll} b_n=s(\alpha _n) \ \ \ \ \ {} &{}if \ n \equiv 0\bmod 3\\ b_n=t(\alpha _n) &{}if \ n \equiv 1 \bmod 3 \ and \ v_p(\alpha _n-t(\alpha _n))= 0\\ b_n=t(\alpha _n)-sign(t(\alpha _n)) &{} if \ n \equiv 1 \bmod 3 \ and \ v_p(\alpha _n-t(\alpha _n))\ne 0\\ b_n=s(\alpha _n)-u(\alpha _n) &{} if \ n \equiv 2 \bmod 3\\ \alpha _{n+1}=\frac{1}{\alpha _n-b_n}. \end{array}\right. } \end{aligned}$$

Remark 13

The choice of the third function u is a little tricky. The function t takes all the negative powers, leaving out the constant term. The function u needs to act on a p-adic number with zero valuation, but it has to leave apart another term with zero valuation, otherwise the third partial quotient will not have null valuation. Clearly, the choice of this function can be done in several ways. In fact, there are a lot of manners to separate the constant term \(a_0\in \{-\frac{p-1}{2},\ldots ,\frac{p-1}{2} \}\) in two nonzero parts. Here we have presented two proposals, but it would surely be interesting to analyze also other options different from ours.

Both of the constructions in Definitions 11 and 12 produce a sequence of partial quotients \(b_0,b_1,\ldots \in \mathbb {Q}_p\) such that, for all \(n\in \mathbb {N}\),

$$\begin{aligned}{\left\{ \begin{array}{ll} v_p(b_{3n+1})<0\\ v_p(b_{3n+2})=0\\ v_p(b_{3n})=0. \end{array}\right. } \end{aligned}$$

We are going to see that also the additional condition required by Theorem 9, i.e.

$$\begin{aligned} v_p(b_{3n+2}b_{3n+3}+1)=0, \ for \ all \ n \in \mathbb {N}, \end{aligned}$$

is satisfied for both algorithm.

Proposition 14

Let \(\alpha \in \mathbb {Q}_p\). Then the partial quotients generated by the new algorithms in Definitions 11 and 12 satisfy the conditions of Theorem 9.

Proof

To prove the claim, we are left to show that

$$\begin{aligned} v_p(b_{3n+2}b_{3n+3}+1)=0, \, \text { for all } n\in \mathbb {N}. \end{aligned}$$

We prove it only for the second algorithm, the other proof is similar. First we notice that, by construction,

$$\begin{aligned} v_p(b_{3n+2}b_{3n+3})=v_p(b_{3n+2})+v(b_{3n+3})=0, \end{aligned}$$

so that \(v_p(b_{3n+2}b_{3n+3}+1)\ge \min \{ v_p(b_{3n+2}b_{3n+3}), v_p(1)\}=0\). Let us show that the case \(v_p(b_{3n+2}b_{3n+3}+1)>0\) can not occur. For all \(n\in \mathbb {N}\),

$$\begin{aligned} \alpha _{3n+2}= \frac{1}{\alpha _{3n+1}-t(\alpha _{3n+1})}=a_0+a_1p+a_2p^2+\cdots . \end{aligned}$$

and

$$\begin{aligned} b_{3n+2}&=s(\alpha _{3n+2})-u(\alpha _{3n+2})=a_0 \mp 1,\\ b_{3n+3}&=s(\alpha _{3n+3})=s\Big (\frac{1}{\alpha _{3n+2}-b_{3n+2}}\Big )=(a_0-b_{3n+2})^{-1}=\pm 1. \end{aligned}$$

Therefore, the condition \(v_p(b_{3n+2}b_{3n+3}+1)=0\) is satisfied if and only if

$$\begin{aligned} b_{3n+2}(a_0-b_{3n+2})^{-1} \equiv (\pm 1) (a_0 \mp 1 ) \equiv -1 \bmod p \end{aligned}$$

is not fulfilled. However, this would imply that \(a_0 \equiv 0 \bmod p\), but this cannot happen, due to the constraints in the algorithm when using the function t. \(\square \)

Finally we prove that the second new algorithm succeed in obtaining the finiteness of the expansion for rational numbers, as it happens for Browkin I and Browkin II. We state it in the following theorem.

Theorem 15

If \(\alpha \in \mathbb Q\), then the second new algorithm (Definition 12) stops in a finite number of steps.

Proof

Let us consider \(\alpha \in \mathbb {Q}\). We are going to show that the algorithm from Definition 12 stops in a finite number of steps when the input is \(\alpha \). By construction we have,

$$\begin{aligned} v_p(\alpha _{3k+1})<0, \ v_p(\alpha _{3k+2})=v_p(\alpha _{3k+3})=0, \end{aligned}$$

so that we can write

$$\begin{aligned} \alpha _{3k+1}&=\frac{N_{3k+1}}{D_{3k+1}p^l}, \qquad \text {with} \ (N_{3k+1},D_{3k+1})=1, \ \ p\not | N_{3k+1}D_{3k+1}, \ \ l\ge 1,\\ \alpha _{3k+2}&=\frac{N_{3k+2}}{D_{3k+2}}, \quad \qquad \text {with} \ (N_{3k+2},D_{3k+2})=1, \ \ p\not | N_{3k+2}D_{3k+2},\\ \alpha _{3k+3}&=\frac{N_{3k+3}}{D_{3k+3}}, \quad \qquad \text {with} \ (N_{3k+3},D_{3k+3})=1, \ \ p\not | N_{3k+3}D_{3k+3}.\\ \end{aligned}$$

Let us notice that for this algorithm, for all \(n\in \mathbb {N}\), the partial quotients are such that \(b_{3n+2}\in \{-\frac{p-1}{2}+1,\ldots ,-1,1,\ldots ,\frac{p-1}{2}-1\}\) and \(b_{3n+3}=\pm 1\), so that

$$\begin{aligned} |b_{3n+2}|\le \frac{p-3}{2},\quad |b_{3n+3}|=1. \end{aligned}$$

Since \(v_p(b_{3n+1})<0\), we can write

$$\begin{aligned} b_{3n+1}=\frac{c_{3n+1}}{p^l}, \ \text {with} \ v_p(c_{3n+1})=0, \ l\ge 1. \end{aligned}$$

The partial quotients \(b_{3n+1}\) are generated by the function t and it has been shown in [1] that

$$\begin{aligned} |c_{3n+1}|\le p^l\left( 1-\frac{1}{p^l}\right) . \end{aligned}$$

For the sake of simplicity, we also write \(c_{3k+2}=b_{3k+2}\) and \(c_{3k+3}=b_{3k+3}\), so that the coefficients \(c_n\) always have zero valuation.

Exploiting \(\alpha _{k+1}=\frac{1}{\alpha _k-b_k}\), we get

$$\begin{aligned} N_{3k+1}(N_{3k}-c_{3k}D_{3k})&=p^lD_{3k}D_{3k+1},\\ N_{3k+2}(N_{3k+1}-c_{3k+1}D_{3k+1})&=p^lD_{3k+1}D_{3k+2},\\ N_{3k+3}(N_{3k+2}-c_{3k+2}D_{3k+2})&=D_{3k+2}D_{3k+3}. \end{aligned}$$

Since \((|N_n|,p|D_n|)=1\) for all \(n\in \mathbb {N}\), then

$$\begin{aligned} |N_{3k+1}|=|D_{3k}|, \ |N_{3k+2}|=|D_{3k+1}|,\ |N_{3k+3}|=|D_{3k+2}|, \end{aligned}$$

and

$$\begin{aligned} |D_{3k+1}|&=\frac{|N_{3k}-c_{3k}D_{3k}|}{p^l}\le \frac{|N_{3k}|+|c_{3k}D_{3k}|}{p^l} =\frac{1}{p^l}|N_{3k}|+\frac{1}{p^l}|D_{3k}|,\\ |D_{3k+2}|&=\frac{|N_{3k+1}-c_{3k+1}D_{3k+1}|}{p^l}\le \frac{1}{p^l}|N_{3k+1}|+\left( 1- \frac{1}{p^l}\right) |D_{3k+1}|,\\ |D_{3k+3}|&=|N_{3k+2}-c_{3k+2}D_{3k+2}|\le |N_{3k+2}|+\left( \frac{p-3}{2} \right) |D_{3k+2}|. \end{aligned}$$

By using the formulas above we may write

$$\begin{aligned}&|N_{3k+3}|+|D_{3k+3}|\le |D_{3k+1}|+\frac{p-1}{2}|D_{3k+2}|\\&\quad \le |D_{3k+1}|+\frac{p-1}{2}\left( \frac{1}{p^l}|N_{3k+1}|+ \frac{p^l-1}{p^l}|D_{3k+1}| \right) \\&\quad =\frac{p-1}{2p^l}|N_{3k+1}|+\frac{p^{l+1}+p^l-p+1}{2p^l}|D_{3k+1}|\\&\quad \le \frac{p-1}{2p^l}|D_{3k}|+\frac{p^{l+1}+p^l-p+1}{2p^l} \cdot \left( \frac{1}{p^l}|N_{3k}|+\frac{1}{p^l}|D_{3k}|\right) \\&\quad =\left( \frac{p^{l+1}+p^l-p+1}{2p^{2l}}\right) |N_{3k}|+\left( \frac{2p^{l+1}-p+1}{2p^{2l}}\right) |D_{3k}|. \end{aligned}$$

We have that \(2p^{l+1}-p+1<2p^{2l}\), since \(p^{2l} \ge p^l\) for every \(l \ge 1\) and consequently we also have \(p^{l+1}+p^l-p+1<2p^{2l}\). Thus, we obtain, for all \(k\in \mathbb {N}\), that

$$\begin{aligned} |N_{3k+3}|+|D_{3k+3}|<|N_{3k}|+|D_{3k}|. \end{aligned}$$

Since the sequence \(\{|N_{3n}|+|D_{3n}|\}_{n\in \mathbb {N}}\) is a strictly decreasing sequence of natural numbers it must be finite and hence \(\alpha \) has a finite continued fraction. \(\square \)

We conclude this section with an example of the continued fraction expansion of a rational number obtained using this algorithm.

Example 16

Let us consider \(p=7\) and let us compute the continued fraction of \(\alpha _0=-\dfrac{1}{5}\in \mathbb {Q}_7\). Its expansion is

$$\begin{aligned} \alpha _0=-3-p+3p^2+\cdots , \end{aligned}$$

so that \(b_0=s(\alpha _0)=-3\) and

$$\begin{aligned} \alpha _1=\frac{1}{\alpha _0-b_0}=\frac{5}{14}=-\frac{1}{p}-3-3p-3p^2-\cdots . \end{aligned}$$

Then the second partial quotient is \(b_1=t(\alpha _1)=-\frac{1}{7}\) and the following complete quotient is

$$\begin{aligned} \alpha _2=\frac{1}{\alpha _1-b_1}=2. \end{aligned}$$

Using the third function we get \(b_2=u(\alpha _2)=1\) and then

$$\begin{aligned} \alpha _3=1=s(\alpha _3)=b_3. \end{aligned}$$

Hence, the finite continued fraction for \(-\dfrac{1}{5}\in \mathbb {Q}_7\) using the algorithm of Definition 12 is

$$\begin{aligned} -\dfrac{1}{5}=\left[ -3,-\frac{1}{7},1,1\right] . \end{aligned}$$

6 Generalization to n steps

The aim of this section is to generalize Theorem 9 to a generic n-step algorithm. On this purpose, we also need several additional conditions on the valuations, thus we introduce the following notation for a family of sequences. Let \(n,m\in \mathbb {N}\), with \(m\ge 2\), we define the family of sequences \(U_m^{(n)}\) as

$$\begin{aligned} U_m^{(0)}=1, \ \ U_m^{(1)}=b_m, \ \ U_m^{(n+1)}=b_{m+n}U_m^{(n)}+U_m^{(n-1)}. \end{aligned}$$

Lemma 17

For every \(n\ge 2\), the partial denominators \(B_n\) can be obtained as:

$$\begin{aligned} B_n=U_2^{(n-1)}B_1+U_3^{(n-2)}B_0. \end{aligned}$$

Proof

Let us prove the claim by induction on n. For \(n=2\) and \(n=3\) it holds since:

$$\begin{aligned} B_2&=b_2B_1+B_0=U_2^{(1)}B_1+U_3^{(0)}B_0,\\ B_3&=b_3B_2+B_1=(b_3b_2+1)B_1+b_3B_0=U_2^{(2)}B_1+U_3^{(1)}B_0. \end{aligned}$$

Now let us suppose that the claim holds at the steps n and \(n+1\), that is:

$$\begin{aligned} B_n&=U_2^{(n-1)}B_1+U_3^{(n-2)}B_0,\\ B_{n+1}&=U_2^{(n)}B_1+U_3^{(n-1)}B_0. \end{aligned}$$

We are going to show that it is true also for \(B_{n+2}\). In fact:

$$\begin{aligned} B_{n+2}&=b_{n+2}B_{n+1}+B_{n}\\&=b_{n+2}(U_2^{(n)}B_1+U_3^{(n-1)}B_0)+(U_2^{(n-1)}B_1+U_3^{(n-2)}B_0)\\&=(b_{n+2}U_2^{(n)}+U_2^{(n-1)})B_1+(b_{n+2}U_3^{(n-1)}+U_3^{(n-2)})B_0\\&=U_2^{(n+1)}B_1+U_3^{(n)}B_0. \end{aligned}$$

It follows that the thesis is true for all \(n\ge 2\). \(\square \)

Remark 18

Notice that Lemma 17 holds also starting from a generic step k. It means that for all \(k\in \mathbb {N}\) and \(n\ge 2\),

$$\begin{aligned}B_{k+n}=U_{k+2}^{(n-1)}B_{k+1}+U_{k+3}^{(n-2)}B_k,\end{aligned}$$

and the proof is similar to the case \(k=0\) seen in Lemma 17.

Theorem 19

Let us consider \(r\in \mathbb {N^+}\) and \(b_0,b_1,\ldots \in \mathbb {Q}_p\) such that, for all \(n\in \mathbb {N}\):

$$\begin{aligned}{\left\{ \begin{array}{ll} v_p(b_{rn+1})<0\\ v_p(b_{rn+i})=0, \ \forall i\in \{2,\ldots ,r\}.\\ \end{array}\right. }. \end{aligned}$$

Moreover let us suppose that, for all \(n\in \mathbb {N}\),

$$\begin{aligned} v_p(U_{rn+2}^{(i)})&=0 \ for \ all \ i\in \{2,\ldots ,r-1\} \text { and for } r \ge 3,\\ v_p(U_{rn+3}^{(i)})&=0 \ for \ all \ i\in \{2,\ldots ,r-2\} \text{ and } \text{ for } r \ge 4. \end{aligned}$$

Then we have, for all \(n\in \mathbb {N}\),

$$\begin{aligned} v_p(B_{rn+1})=v_p(B_{rn+2})=\cdots =v_p(B_{rn+r})>v_p(B_{rn+r+1}). \end{aligned}$$

Proof

Let us prove the claim by induction on n.

Base step

We prove the thesis for \(n=0\). The valuation of the first denominator is:

$$\begin{aligned} v_p(B_1)=v_p(b_1)<0. \end{aligned}$$

By Lemma 17, for \(i\in \{2,\ldots ,r\}\),

$$\begin{aligned} v_p(B_i)&=v_p(U_2^{(i-1)}B_1+U_3^{(i-2)}B_0)=v_p(U_2^{(i-1)}B_1)=v_p(b_2B_1)=v_p(B_1). \end{aligned}$$

At the following step, since \(v_p(b_{r+1})<0\), we get:

$$\begin{aligned} v_p(B_{r+1})=v_p(b_{r+1}B_r+B_{r-1})=v_p(b_{r+1})+v_p(B_r)<v_p(B_r). \end{aligned}$$

Hence, the claim is true for \(n=0\).

Induction step

Let us suppose that the thesis holds for a generic \(n\in \mathbb {N}\), that is:

$$\begin{aligned} v_p(B_{rn+1})=v_p(B_{rn+2})=\cdots =v_p(B_{rn+r})>v_p(B_{rn+r+1}). \end{aligned}$$

We want to prove the claim for \(n+1\).

Here we use Remark 18 with \(k=r(n+1)\). Now, for \(i\in \{2,\ldots ,r\}\),

$$\begin{aligned} v_p(B_{r(n+1)+i})&=v_p(U_{r(n+1)+2}^{(i-1)}B_{r(n+1)+1}+U_{r(n+1)+3}^{(i-2)}B_{r(n+1)})\\&=v_p(U_{r(n+1)+2}^{(i-1)}B_{r(n+1)+1})\\&=v_p(U_{r(n+1)+2}^{(i-1)})+v_p(B_{r(n+1)+1})=v_p(B_{r(n+1)+1}). \end{aligned}$$

At the following step, since \(v_p(b_{r(n+2)+1})<0\), then:

$$\begin{aligned} v_p(B_{r(n+2)+1})&=v_p(b_{r(n+2)+1}B_{r(n+2)}+B_{r(n+2)-1})\\&=v_p(b_{r(n+2)+1}B_{r(n+2)})<v_p(B_{r(n+2)}). \end{aligned}$$

The induction is then complete and the claim holds for all \(n\in \mathbb {N}\). \(\square \)

Corollary 20

Let \(r\in \mathbb {N^+}\) and \(b_0,b_1,\ldots \) as in Theorem 19. Then the continued fraction \([b_0,b_1,\ldots ]\) is convergent to a p-adic number.

Proof

Using Remark 3, the continued fraction \([b_0,b_1,\ldots ]\) converges in \(\mathbb {Q}_p\) if and only if

$$\begin{aligned} \lim \limits _{n\rightarrow +\infty } v_p(B_nB_{n+1})= -\infty . \end{aligned}$$

By Theorem 19 we have that, for all \(n\in \mathbb {N}\),

$$\begin{aligned} v_p(B_{rn+1}B_{rn+2})=\cdots =v_p(B_{rn+r-1}B_{rn+r})>v_p(B_{rn+r}B_{rn+r+1}), \end{aligned}$$

so that the sequence \(v_p(B_nB_{n+1})\) is decreasing and divergent to \(-\infty \). \(\square \)

By Corollary 20, we obtain the convergence of a p-adic continued fractions algorithm generating the partial quotients as

$$\begin{aligned} {\left\{ \begin{array}{ll} v_p(b_{rn+1})<0\\ v_p(b_{rn+2})=0\\ v_p(b_{rn+3})=0\\ \ldots \\ v_p(b_{rn+r})=0. \end{array}\right. } \end{aligned}$$
(5)

With a construction similar to the one made in Example 4, it can be proved that the conditions of Theorem 19 are necessary for the p-adic convergence.

7 Conclusions

In this paper we have analyzed the convergence of p-adic continued fractions in order to give a better understanding for the design of an algorithm that enjoys some properties similar to those holding for classical continued fractions in \(\mathbb {R}\). At the present moment such an algorithm does not exist, because an analogue of Lagrange’s Theorem has not been proved yet. In Theorem 7, we have characterized the strict decrease of the valuations \(v_p(B_n B_{n+1})\), used by Browkin in [4] and [5]. This characterization guarantees the p-adic convergence of all the algorithms generating partial quotients such that \(v_p(b_n)+v_p(b_{n+1})<0\) for all \(n\in \mathbb {N}\). Outside from this hypothesis, we have also obtained some effective conditions for the convergence of a p-adic continued fractions with only one negative partial quotient each r steps. In particular, Browkin’s continued fractions in [4] and [5] are respectively the cases when \(r=1\) and \(r=2\). For the case \(r=3\) we have proposed some actual algorithms, proving that one of them terminates in a finite number of steps when processing a rational number.