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.

A370004 Least k>0 such that the decimal expansion of k^2 contains k+n as a substring.

Original entry on oeis.org

1, 11, 2, 13, 104, 14, 3, 15, 108, 16, 11, 17, 4, 39, 18, 77, 760, 19, 52, 117, 5, 118, 34, 21, 120, 121, 22, 41, 123, 23, 6, 125, 12, 24, 42, 128, 504, 25, 352, 130, 16, 26, 7, 133, 377, 27, 322, 135, 136, 44, 26, 393, 24, 747, 139, 29, 8, 141, 108, 142, 30, 143, 22, 144, 380, 31, 606, 146, 1064, 147, 32
Offset: 0

Views

Author

Giorgos Kalogeropoulos, Feb 07 2024

Keywords

Comments

This sequence is defined for all n. Proof: Given n, consider k = 10^x + n where 10^x > n^2. Since k^2 = (k+n) * 10^x + n^2, k^2 contains k+n as a substring. Furthermore, x = ceiling(log_10(1+n^2)) satisfies the inequality, therefore a(n) <= 10^ceiling(log_10(1+n^2)) + n. - Jason Yuen, Feb 26 2024

Examples

			a(3) = 13 because 13 is the least positive integer such that 13^2 = 169 contains 13 + 3 = 16 as a substring.
a(4) = 104 because 104 is the least positive integer such that 104^2 = 10816 contains 104 + 4 = 108 as a substring.
		

Crossrefs

Programs

  • Mathematica
    Table[k=1;While[!StringContainsQ[ToString[k^2],ToString[k+n]],k++];k,{n,0,70}]
    lks[n_]:=Module[{k=1},While[SequenceCount[IntegerDigits[k^2],IntegerDigits[k+n]]==0,k++];k]; Array[lks,80,0] (* Harvey P. Dale, May 26 2025 *)
  • PARI
    a(n) = my(k=1); while (#strsplit(Str(k^2), Str(k+n))<2, k++); k; \\ Michel Marcus, Feb 07 2024
    
  • Python
    from itertools import count
    def a(n): return next(k for k in count(1) if str(k+n) in str(k*k))
    print([a(n) for n in range(71)]) # Michael S. Branicky, Feb 07 2024