CMIMC 2017 Number Theory Problem 6

Find the largest positive integer N satisfying the following properties:

  • N is divisible by 7;
  • Swapping the i^{\text {th }} and j^{\text {th }} digits of N (for any i and j with i \neq j ) gives an integer which is not divisible by 7.