For this Question: Given an integer N which is to be reduced to 1 by performing the given operation:-
In one operation you can subtract any divisor of N other than N itself from N. 
Your task is to find the minimum number to reduce N to 1.The input contains a single integer N.

<b>Constraints:-</b>
1 <= N <= 1000Print the minimum number of operations need to convert N to 1.Sample Input 1:-
5

Sample Output 1:-
3

<b>Explanation:-</b>
5 - > 4 - > 2 - > 1

Sample Input 2:-
8

Sample Output 2:-
3
, I have written this Solution Code: #include <bits/stdc++.h>
using namespace std;
int dp[1001];

int solve(int n){
    if(n<=1){
        return 0;
    }
    if(dp[n]==-1){
        int ans = INT_MAX;
    int x = sqrt(n);
    ans=min(ans,solve(n-1));
    for(int i=2;i<=x;i++){
        if(n%i==0){
        ans=min(ans,solve(n-i));
        ans=min(ans,solve(n-(n/i)));
    }}
    dp[n]=ans+1;
    }
    return dp[n];
}
int main(){
    for(int i=0;i<1001;i++){
        dp[i]=-1;
    }

    int n;
    cin>>n;
    cout<<solve(n);
}
, In this Programming Language: C++, Now tell me if this Code is compilable or not?