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.
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
Offset: 0
Examples
If n = 102, c = 21, C = 210, a(102) = 210 - 21 = 189.
Links
- Rémy Sigrist, Table of n, a(n) for n = 0..10000
Programs
-
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 *)
-
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
Formula
a(n) = 0 iff n belongs to A010785. - Rémy Sigrist, Sep 22 2021
Extensions
More than the usual number of terms are shown in order to distinguish this from similar sequences.
Comments