TLE issues in python

hi everyone!!i have been facing some TLE issues while solving dp problem in python…
ill share the question link and my code here.

  1. n, k = [int(i) for i in input().split()]
  2. dp = [[-1]*(2005) for i in range(2005)]
  3. MOD=10**9+7
  4. def solve(x,k):
  5. if(k==0):
  6. return 1
  7. elif(dp[x][k]!=-1):
  8. return dp[x][k]
  9. ans=0
  10. for i in range(x,n+1,x):
  11. ans+=solve(i,k-1)
  12. dp[x][k]=ans%MOD
  13. return dp[x][k]
  14. res=solve(1,k)
  15. print(res)

i used top down approach it throws tle.when i changed the recursionlimit to 10**6 and added threading but it throws memory limit exceeded…can anyone help me out this… and please dont tell me to code in iterative manner coz im just a beginner…