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!)
A360443 Smallest integer m > n such that the multiset of nonzero decimal digits of m is exactly the same as the multiset of nonzero decimal digits of n. 1
10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 101, 21, 31, 41, 51, 61, 71, 81, 91, 200, 102, 202, 32, 42, 52, 62, 72, 82, 92, 300, 103, 203, 303, 43, 53, 63, 73, 83, 93, 400, 104, 204, 304, 404, 54, 64, 74, 84, 94, 500, 105, 205, 305, 405, 505, 65, 75, 85, 95, 600 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,1
COMMENTS
Equivalently: a(n) is the number whose decimal digits are the next larger permutation of those of n, allowing any number of leading zeros.
LINKS
PROG
(PARI) A360443(n)={forperm(concat(0, digits(n)), p, n||return(fromdigits(Vec(p))); n=0)} \\ M. F. Hasler, Feb 23 2023; similar idea also suggested by Ruud H.G. van Tol.
(Python) # From Arthur O'Dwyer, edited by M. F. Hasler, Feb 22 2023
def A360443(n):
s = '0' + str(n)
i = next(i for i in range(len(s) - 1, 0, -1) if s[i-1] < s[i])
tail = s[i-1:]
j = min((ch, j) for j, ch in enumerate(tail) if s[i-1] < ch)[1]
s = s[:i-1] + tail[j] + ''.join(sorted(tail[:j] + tail[j+1:]))
return int(s)
for n in range(100): print(n, A360443(n))
CROSSREFS
Cf. A057168 (analog for base 2), A354049 (digits of a(n) contain those of n as sub-multiset).
Cf. A009994 (numbers with digits in nondecreasing order: don't appear in this sequence).
Sequence in context: A370400 A156819 A139079 * A209932 A011540 A098394
KEYWORD
nonn,easy,base
AUTHOR
Marc LeBrun and M. F. Hasler, Feb 22 2023
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 July 24 15:22 EDT 2024. Contains 374584 sequences. (Running on oeis4.)