login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A347688 Let c (resp. C) be the smallest (resp. largest) number that can be obtained by cyclically permuting the digits of n; a(n) = C - c. 3
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 9, 18, 27, 36, 45, 54, 63, 72, 18, 9, 0, 9, 18, 27, 36, 45, 54, 63, 27, 18, 9, 0, 9, 18, 27, 36, 45, 54, 36, 27, 18, 9, 0, 9, 18, 27, 36, 45, 45, 36, 27, 18, 9, 0, 9, 18, 27, 36, 54, 45, 36, 27, 18, 9, 0, 9, 18, 27, 63, 54, 45, 36, 27, 18, 9, 0, 9, 18, 72, 63, 54, 45, 36, 27, 18, 9, 0, 9, 81, 72, 63, 54, 45, 36, 27, 18, 9, 0, 99, 99, 189, 279, 369, 459, 549, 639, 729, 819, 99, 0, 99 (list; graph; refs; listen; history; text; internal format)
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
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
Sequence in context: A273086 A332093 A056965 * A151949 A341486 A349825
KEYWORD
nonn,look,base
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

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified March 28 14:38 EDT 2024. Contains 371254 sequences. (Running on oeis4.)