Just to clarify your notation here, are you saying:

(1)

or

(2)

I believe you are referring to (2) here. Are you seeking a computer program that will input N and count all possible solutions - easy - or are you looking for a mathematical formula that will tell you how many solutions there are - hard?