Help with the code for Puppy and GCD.

My code is giving WA for Puppy and GCD.
Code= https://www.codechef.com/viewsolution/7557753

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: https://discuss.codechef.com/questions/73360/puppygcd-editorial