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.

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.

This page as a plain text file.
%I A347688 #58 Jul 09 2025 04:56:35
%S A347688 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,
%T A347688 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,
%U A347688 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
%N 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.
%C A347688 Agrees with A151949 for n <= 101.
%C A347688 All terms are multiples of 9 (cf. A347689).
%C A347688 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
%C A347688 For any cyclic number N, there must exist a cyclic permutation P of N for which a(P) = P. - _Joseph Rozhenko_, Oct 07 2021
%C A347688 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
%H A347688 Rémy Sigrist, <a href="/A347688/b347688.txt">Table of n, a(n) for n = 0..10000</a>
%F A347688 a(n) = 0 iff n belongs to A010785. - _Rémy Sigrist_, Sep 22 2021
%e A347688 If n = 102, c = 21, C = 210, a(102) = 210 - 21 = 189.
%p A347688 A347688 := proc(n)
%p A347688         local dgs,C,c,ndgs,r ;
%p A347688         dgs := convert(n,base,10) ;
%p A347688         ndgs := nops(dgs) ;
%p A347688         C := digcatL(dgs) ;
%p A347688         c := C ;
%p A347688         for r from 0 to ndgs-1 do
%p A347688                 C := max(C,digcatL(dgs)) ;
%p A347688                 c := min(c,digcatL(dgs)) ;
%p A347688                 dgs := ListTools[Rotate](dgs,1) ;
%p A347688         end do:
%p A347688         C-c ;
%p A347688 end proc: # _R. J. Mathar_, Sep 27 2021
%t A347688 {0}~Join~Table[First@Differences@MinMax[FromDigits/@(RotateLeft[IntegerDigits@n,#]&/@Range@IntegerLength@n)],{n,112}] (* _Giorgos Kalogeropoulos_, Sep 22 2021 *)
%o A347688 (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
%o A347688 (Python)
%o A347688 def a(n):
%o A347688     s = str(n)
%o A347688     cyclic_perms = [int("".join(s[i:] + s[:i])) for i in range(len(s))]
%o A347688     c, C = min(cyclic_perms), max(cyclic_perms)
%o A347688     return C - c
%o A347688 print([a(n) for n in range(113)]) # _Michael S. Branicky_, Sep 26 2021
%Y A347688 Cf. A010785, A056965, A151949, A163380, A163381, A347689.
%K A347688 nonn,look,base
%O A347688 0,11
%A A347688 _N. J. A. Sloane_, Sep 22 2021, following a suggestion from _Joseph Rozhenko_
%E A347688 More than the usual number of terms are shown in order to distinguish this from similar sequences.