OFFSET
1,1
COMMENTS
The 1st problem of British Mathematical Olympiad (BMO) in 1995 (see link) asked to find all positive integers whose squares end in three 4’s (A039685); this sequence is the subsequence of these integers whose squares also start in precisely three 4's (no four or more 4's). Two such infinite subsequences are proposed below.
When a square starts and ends with digits ddd, then ddd is necessarily 444.
The first 3 digits of terms are either 210, 666 or 667, while the last 3 digits are either 038, 462, 538 or 962 (see examples).
From Marius A. Burtea, Nov 09 2021 : (Start)
The sequence is infinite because the numbers 667038, 6670038, 66700038, 667000038, ..., 667*10^k + 38, k >= 3, are terms because are square 444939693444, 44489406921444, 4448895069201444, 444889050692001444, 44488900506920001444, ...
Also, 6663462, 66633462, 666333462, 6663333462, ..., (1999*10^k + 386) / 3, k >= 4, are terms and have no digits 0, because their squares are 44401725825444, 4440018258105444, 444000282580905444, 44400012825808905444,
4440001128258088905444, ... (End)
REFERENCES
A. Gardiner, The Mathematical Olympiad Handbook: An Introduction to Problem Solving, Oxford University Press, 1997, reprinted 2011, Pb 1 pp. 55 and 95-96 (1995)
LINKS
British Mathematical Olympiad 1975, Problem 1.
EXAMPLE
666462 is a term since 666462^2 = 444171597444.
21038 is not a term since 21038^2 = 442597444.
MATHEMATICA
Select[Range[100, 7*10^6], (d = IntegerDigits[#^2])[[1 ;; 3]] == d[[-3 ;; -1]] == {4, 4, 4} && d[[-4]] != 4 && d[[4]] != 4 &] (* Amiram Eldar, Nov 09 2021 *)
PROG
(Python)
from itertools import count, takewhile
def ok(n):
s = str(n*n); return len(s.rstrip("4")) == len(s.lstrip("4")) == len(s)-3
def aupto(N):
ends = [38, 462, 538, 962]
r = takewhile(lambda x: x<=N, (1000*i+d for i in count(0) for d in ends))
return [k for k in r if ok(k)]
print(aupto(6668962)) # Michael S. Branicky, Nov 09 2021
(Magma) fd:=func<n|Seqint(Intseq(n*n)) mod 1000 eq 444 and Seqint(Intseq(n*n)) mod 10000 ne 4444>; fs:=func<n|Seqint(Reverse(Intseq(n*n))) mod 1000 eq 444 and Seqint(Reverse(Intseq(n*n))) mod 10000 ne 4444>; [n:n in [1..6700000]|fd(n) and fs(n)]; // Marius A. Burtea, Nov 09 2021
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Bernard Schott, Nov 09 2021
STATUS
approved