What do you mean by "work"? With manual focus only and manual exposure only nearly all lenses made after about 1977 will take a picture with nearly all Nikon digital bodies. If you want auto focus and auto exposure the choice is more restricted.
Except the newest AF-P lenses. These lenses won't work with the older Nikon digital camera bodies because they have a new type of autofocus that the older cameras can't use and manual focus modes must be switched on in camera, and on the older bodies (which aren't even that old yet) they don't have the menu option to allow you to switch them, so you can't focus in either manual or autofocus modes.
https://nikonrumors.com/2018/02/07/...mpatilble-with-older-nikon-dslr-cameras.aspx/
But all of the film SLR lenses should work with any body, though things like autofocus and metering may not. Nikon has three autofocus systems, AF, AF-S, and AF-P. The AF are screw drive and require a body with a screw drive to operate them. This is usually found on the higher end Nikons. AF-S is their first in the lens autofocus system and will work on most, if not all, of their DSLR's. AF-P is their newest, and won't work on most of Nikon's digital cameras (except the newest ones).
Nikon also has three metering systems with their lenses. The old manual lenses don't meter, so you'll have to set the camera to full manual to use them. Nikon D lenses have an aperture ring, but can also be set to meter automatically. Nikon G lenses don't have an aperture ring, so the aperture has to be set in camera. On old film cameras without software controls, they will only work at their smallest aperture, and on many older film cameras, the aperture on these lenses can only be operated in auto, program, or exposure priority modes. Of course, the G and D lenses won't meter on older Nikon film bodies because they don't have the linkage arm to communicate aperture with the camera.
Up until the AF-P, Nikon did a good job of keeping their lenses up to date, and at least somewhat functional with all of their camera, both past and future. There are more technicalities that I didn't go into, such as non-Ai, Ai, AiS, etc.