#C11117. Permuted Multiples
Permuted Multiples
Permuted Multiples
Given a positive integer \( n \), find the smallest integer \( x \) (with \( x \ge n \)) such that for every multiplier \( k \) in the set \( \{2,3,4,5,6\} \), the number \( k \times x \) is a permutation of the digits of \( x \). In other words, the digits of \( kx \) can be rearranged to form \( x \).
Example: When \( x = 142857 \), it can be verified that \( 2x = 285714 \), \( 3x = 428571 \), ..., \( 6x = 857142 \) are all rearrangements of the digits of \( 142857 \). Hence, \( 142857 \) is a valid answer when the lower bound \( n \) is \( 1 \) (or any value \( \leq 142857 \)).
inputFormat
The input consists of a single integer \( n \) (\( 1 \le n \le 10^9 \)) provided via standard input. This integer represents the lower bound for the search for \( x \).
outputFormat
Output a single integer \( x \), the smallest number greater than or equal to \( n \) that satisfies the condition that \( 2x, 3x, 4x, 5x, \) and \( 6x \) are all permuted multiples of \( x \).
## sample1
142857
</p>