login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A343740
a(n) is the digit position of the first appearance of the last digit to appear in sqrt(n) (or -1 if n is a square).
4
-1, 19, 23, -1, 37, 39, 45, 36, -1, 27, 17, 25, 15, 36, 19, -1, 20, 36, 25, 37, 28, 13, 27, 52, -1, 39, 17, 38, 27, 26, 17, 23, 24, 37, 19, -1, 25, 26, 26, 41, 58, 57, 25, 12, 25, 22, 24, 19, -1, 33, 48, 23, 41, 49, 23, 32, 32, 23, 30, 19, 17, 31, 27, -1, 24
OFFSET
1,2
COMMENTS
A343739(n) is the last digit to appear in the decimal expansion of sqrt(n) (or -1 if n is a square), so a(n) is the digit position of the first appearance of the digit A343739(n) in sqrt(n).
(The first digit of sqrt(n) is counted as digit position 1; the decimal point is disregarded.)
FORMULA
a(100^q*n) = a(n), q > 0. - Bernard Schott, Jul 29 2021
EXAMPLE
a(2)=19 because A343739(2)=8 and the first appearance of an 8 in sqrt(2) = 1.414213562373095048... is at the 19th digit;
a(24)=52 because A343739(24)=0 and the first appearance of a 0 in sqrt(24) = 4.898979485566356196394568149411782783931894961313340... is at the 52nd digit.
MATHEMATICA
Table[If[IntegerQ@ Sqrt@ n, -1, Function[s, Max@ Array[FirstPosition[s, #][[1]] &, 10, 0]]@ RealDigits[Sqrt[n], 10, 120][[1]]], {n, 65}] (* Michael De Vlieger, Jul 06 2021 *)
PROG
(Python 3.8+)
from math import isqrt
def A343740(n):
i = isqrt(n)
if i**2 == n:
return -1
m, dset, pos = n, set(), 0
for d in (int(s) for s in str(i)):
dset.add(d)
pos += 1
if len(dset) == 10:
return pos
while len(dset) < 10:
m *= 100
d = isqrt(m) % 10
dset.add(d)
pos += 1
return pos # Chai Wah Wu, Jul 07 2021
CROSSREFS
KEYWORD
sign,base
AUTHOR
Jon E. Schoenfield, Jul 05 2021
STATUS
approved