Your understanding of recursion is wrong. All these nested functions calls will finally return back to where you started and thus numPrime() will return 1 to main() for every odd number and 0 for every even number.
I think you have forgotten that all these function calls return to the caller and not directly to main().
Bye, Andreas