Reduce a number to one in minimum steps(Dynamic Programming)

It is always giving 1 as answer. What is the mistake?

hey @vrindabansal05, in line no 35 and 37 it should be 1000 instead of n and dp[i] instead of dp[n] respectively.