i think that it has been mentioned before, the focal length really depends on your shooting style.
most would advocate the 50mm and the 85mm as the top 2 placements for portrait prime lenses on digital (1.5x crop), the 105 and the 35 are usually take distant 3rd and 4th placements. the only focal lenght with an available nikkor lense to AF on the D40 body is the AF-s105f2.8microVR (not the 105f2DC).
if budget was not a contraint, you could consider the AF-s28-70f2.8... but that'll be quite a stretch of the budget. else can also consider the sigma 24-70f2.8 or the 50-150f2.8... or get comfortable with manual focusing through the "tiny" viewfinder... :sweat: