Explain loop of recursion

I am not getting this
for(int i=1 ; I<=k;I++)
{
ans=ans+f(n-1,k);
}

@thapliyalsam55 as you can see the ans of the ladder n stair if 1,2,3 steps allowed is ans(n-1) + ans(n-2) + ans(n-3) so for k it is i 1 to k ans+=(n-i,k) (its n - i not n - 1)
i hope your doubt is cleared if yes dont forget to mark the doubt resolved :smiley: