OFFSET
1,2
COMMENTS
John D. Cook's blog (see link below) provides a proof that "if a three-digit number is divisible by 37, it remains divisible by 37 if you rotate its digits."
LINKS
John D. Cook, Rotating multiples of 37.
EXAMPLE
For a(4)=27, 405 is a 3-digit multiple of 27, and the two rotations of 405 (i.e., 54 and 540) are also multiples of 27.
For a(5)=37, 185 is a 3-digit multiple of 37, and the two rotations of 185 (i.e., 851 and 518) are also multiples of 37.
For a(9)=2439, 12195 is a 5-digit multiple of 2439, and the four rotations of 12195 (i.e., 21951, 19512, 95121 and 51219) are also multiples of 2439.
PROG
(Python)
def rotate(str):
first_char = str[0 : 1]
remaining_chars = str[1 :]
return (remaining_chars + first_char)
def get_rotations(n):
n_as_str = str(n)
rotations = []
rotation_as_str = n_as_str
for i in range(len(n_as_str) - 1):
rotation_as_str = rotate(rotation_as_str)
rotations.append(int(rotation_as_str))
return rotations
seq = []
max_n = 9999999
for n in range(1, max_n + 1):
n_len = len(str(n))
factor = 2
while True:
prod = n * factor
prod_len = len(str(prod))
if prod_len < n_len + 1:
factor = factor + 1
elif prod_len > n_len + 1:
seq.append(n)
break
else:
# prod_len == n_len + 1
rotations = get_rotations(prod)
if all(rotation % n == 0 for rotation in rotations):
factor = factor + 1
else:
break
print(seq)
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Robert C. Lyons, Feb 14 2023
EXTENSIONS
a(25)-a(35) from Chai Wah Wu, Feb 24 2023
STATUS
approved