OFFSET
0,11
COMMENTS
Agrees with A151949 for n <= 101.
All terms are multiples of 9 (cf. A347689).
Repeatedly applying the operation of subtracting the smallest cyclic permutation from the largest produces interesting sequences. It appears that n-digit numbers converge to a small number m << n of loops. Any 3-digit number converges to one of two loops of length 3: (189, 729, 675) and (378, 459, 486); any 4-digit number to either of (189, 729, 675) or a loop of length 25; any 5-digit number to one of three loops of length 3: (38007, 79335, 59778), (48780, 82926, 65853), or (29889, 69003, 89667), and so on. For 6-digit numbers there are 10 loops (of lengths 1, 2, 3, 10, 12 or 60). - Joseph Rozhenko, Oct 05 2021
For any cyclic number N, there must exist a cyclic permutation P of N for which a(P) = P. - Joseph Rozhenko, Oct 07 2021
An interesting plot of this sequence comes up when the axes are not n vs. a(n), but rather C vs. c. In other words, each number a(n) is represented on the X axis by C (largest number that can be obtained by cyclically permuting the digits of n) and on the Y axis as c (smallest number that can be obtained by cyclically permuting the digits of n). - Joseph Rozhenko, Jan 26 2022
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..10000
FORMULA
a(n) = 0 iff n belongs to A010785. - Rémy Sigrist, Sep 22 2021
EXAMPLE
If n = 102, c = 21, C = 210, a(102) = 210 - 21 = 189.
MAPLE
A347688 := proc(n)
local dgs, C, c, ndgs, r ;
dgs := convert(n, base, 10) ;
ndgs := nops(dgs) ;
C := digcatL(dgs) ;
c := C ;
for r from 0 to ndgs-1 do
C := max(C, digcatL(dgs)) ;
c := min(c, digcatL(dgs)) ;
dgs := ListTools[Rotate](dgs, 1) ;
end do:
C-c ;
end proc: # R. J. Mathar, Sep 27 2021
MATHEMATICA
{0}~Join~Table[First@Differences@MinMax[FromDigits/@(RotateLeft[IntegerDigits@n, #]&/@Range@IntegerLength@n)], {n, 112}] (* Giorgos Kalogeropoulos, Sep 22 2021 *)
PROG
(PARI) a(n, base=10) = { my (c=n, C=n, d=digits(n, base)); for (k=1, #d, my (r=fromdigits(concat(d[k+1..#d], d[1..k]), base)); c=min(c, r); C=max(C, r)); C-c } \\ Rémy Sigrist, Sep 22 2021
(Python)
def a(n):
s = str(n)
cyclic_perms = [int("".join(s[i:] + s[:i])) for i in range(len(s))]
c, C = min(cyclic_perms), max(cyclic_perms)
return C - c
print([a(n) for n in range(113)]) # Michael S. Branicky, Sep 26 2021
CROSSREFS
KEYWORD
AUTHOR
N. J. A. Sloane, Sep 22 2021, following a suggestion from Joseph Rozhenko.
EXTENSIONS
More than the usual number of terms are shown in order to distinguish this from similar sequences.
STATUS
approved