Help with the code for Puppy and GCD.

My code is giving WA for Puppy and GCD.

Help me and tell where i am wrong.

The way i solved it is find out the max value you get when you find N%i, where 2<=i<=K, and print that max value.

You can refer to the editorial of the problem here: