cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A343739 a(n) is the last digit to appear in sqrt(n) (or -1 if n is a square).

This page as a plain text file.
%I A343739 #21 Aug 06 2021 05:53:17
%S A343739 -1,8,4,-1,5,6,8,5,-1,4,8,2,8,0,5,-1,8,3,1,0,3,3,6,0,-1,6,8,4,9,8,9,7,
%T A343739 1,6,2,-1,4,3,1,1,9,1,9,1,1,4,7,4,-1,9,0,4,6,0,3,0,1,4,3,0,3,2,6,-1,1,
%U A343739 7,0,7,5,1,0,6,9,9,9,5,5,9,2,3,-1,2,6,2
%N A343739 a(n) is the last digit to appear in sqrt(n) (or -1 if n is a square).
%C A343739 For the digit position in sqrt(n) at which the digit a(n) first appears, see A343740.
%F A343739 a(100^q*n) = a(n), q > 0. - _Bernard Schott_, Jul 24 2021
%e A343739 a(2)=8 because 8 is the last digit to appear in sqrt(2) = 1.414213562373095048...;
%e A343739 a(24)=0 because 0 is the last digit to appear in sqrt(24) = 4.898979485566356196394568149411782783931894961313340...
%t A343739 Table[If[IntegerQ@ Sqrt@ n, -1, Function[s, FirstPosition[#, Max@ #][[1]] - 1 &@ Array[FirstPosition[s, #][[1]] &, 10, 0]]@ RealDigits[Sqrt[n], 10, 120][[1]]], {n, 84}] (* _Michael De Vlieger_, Jul 06 2021 *)
%o A343739 (Python 3.8+)
%o A343739 from math import isqrt
%o A343739 def A343739(n):
%o A343739     i = isqrt(n)
%o A343739     if i**2 == n:
%o A343739         return -1
%o A343739     m, dset = n, set()
%o A343739     for d in (int(s) for s in str(i)):
%o A343739         dset.add(d)
%o A343739         if len(dset) == 10:
%o A343739             return d
%o A343739     while len(dset) < 10:
%o A343739         m *= 100
%o A343739         d = isqrt(m) % 10
%o A343739         dset.add(d)
%o A343739     return d # _Chai Wah Wu_, Jul 07 2021
%Y A343739 Cf. A023961, A343740, A343741, A343742.
%K A343739 sign,base
%O A343739 1,2
%A A343739 _Jon E. Schoenfield_, Jul 05 2021