If I have numbers from 1 to N and I want to select K out of them.

In how many ways I can select these K numbers such that they contain at least two consecutive numbers.

For example if N=7 and K=3, I want to select combinations such as {1,2,3) , {2,3,7} , {3,5,6} but not {1,3,5} or {2,4,7} .....

And another question,what about the number of combinations when specifying the minimum distance D between numbers,for example instead of selecting consecutive numbers (D=1), I want to specify the minimum distance allowed between numbers, i.e if D=2, only combinations such as {1,3,5} or {1,5,7} .... are allowed or if D=3 only {1,4,7} is allowed.

I there a way to create a general formula that takes N,K and D and give me the number of combinations allowed?