This is a lens you might want to get since the price is so darn good and i hear nothing but good things about this prime lens. It will work on your D40 & D40x but will only manual focus. I've read tons of great things on this lens so i'm looking to get one as soon as possible. Being a prime lens means theres no zoom so you have to move closer or move back. Here's what Mr. Ken Rockwell has to say about this lens.
Check it out Here!