If i have a large number (<=10^5 Digits) how can i tell that if i can shuffle the number so that it become a multiple of 30 . if it is possible then i have to find the maximum multiple . Suppose if i have this number 97980 if i make any combination of this number , all the combinations will be divisible by 30 , but the maximum one is 99870 . How can i shuffle this very large number and know whether it is possible or not ?
2025-01-14 12:32:07.1736857927
How to shuffle a number so that it can be maximum multiple of the number 30 ?
897 Views Asked by CodeHead https://math.techqa.club/user/codehead/detail At
2
Fortunately (or unfortunately) shuffling digits does not affect whether a number is divisible by 3.
Casting-out-nines will quickly tell you whether a number is divisible by three. If so, then you need some digit to be zero and to transfer this to the units place, in order to have a result that is divisible by $30$.
Otherwise it is not possible to achieve this divisibility by $30$.
To maximize the multiple of $30$, just sort the digits in descending order from left to right (all big digits in high-order positions).