Monday, December 12, 2011

C++ question. The nth harmonic number is defined non-recursively as: 1 +1/2 + 1/3 + 1/4 + ... + 1/n. Come up?

The nth harmonic number is defined non-recursively as: 1 +1/2 + 1/3 + 1/4 + ... + 1/n. Come up with a recursive definition and use it to guide you to write a function definition for a double -valued function named harmonic that accepts an int parameters n and recusrively calculates and returns the nth harmonic number.

No comments:

Post a Comment