Implemented the NPV function in ruby and C