login
Successive approximations to 7-adic integer sqrt(2).
3

%I #32 Dec 05 2022 11:06:29

%S 0,3,10,108,2166,4567,38181,155830,1802916,24862120,266983762,

%T 1961835256,5916488742,19757775943,116646786350,9611769806236,

%U 42844700375837,275475214363044,6789129606004840,75182500718243698

%N Successive approximations to 7-adic integer sqrt(2).

%D K. Mahler, Introduction to p-Adic Numbers and Their Functions, Cambridge, 1973, p. 35.

%H Seiichi Manyama, <a href="/A034945/b034945.txt">Table of n, a(n) for n = 0..1010</a>

%o (PARI) seq(n)={my(v=vector(n), i=1, k=0); while(i<#v, k++; my(t=truncate(sqrt(2 + O(7^k)))); if(t > v[i], i++; v[i]=t)); v} \\ _Andrew Howroyd_, Nov 03 2018

%o (Ruby)

%o def A034945(n)

%o ary = [0]

%o a, mod = 3, 7

%o while ary.size - 1 < n

%o b = a % mod

%o ary << b if b != ary[-1]

%o a = b * b + b - 2

%o mod *= 7

%o end

%o ary

%o end

%o p A034945(100) # _Seiichi Manyama_, Aug 03 2017

%o (Python)

%o def a034945(n):

%o ary=[0]

%o a, mod=3, 7

%o while len(ary) - 1<n:

%o b=a%mod

%o if b!=ary[-1]: ary.append(b)

%o a=b**2 + b - 2

%o mod*=7

%o return ary

%o print(a034945(100)) # _Indranil Ghosh_, Aug 03 2017, after Ruby

%Y Cf. A290557.

%K nonn,easy

%O 0,2

%A _N. J. A. Sloane_