Best writers. Best papers. Let professionals take care of your academic papers

Order a similar paper and get 15% discount on your first order with us
Use the following coupon "FIRST15"
ORDER NOW

Implement a recursive function for computing the n-th Harmonic

Implement a recursive function for computing the n-th Harmonic

number: 

H

n

=∑

n

i=1

1

i

/

.

Here you have some examples of harmonic numbers.

H1 = 1

H2 = 1 + 1/2 = 1.5

H3 = 1 + 1/2 + 1/3 = 1.8333

H4 = 1 + 1/2 + 1/3 + 1/4 = 2.0833 ATTACHMENT PREVIEW Download attachment/*************************************************Week 4 lesson:**implementing a recursive factorial function **************************************************/#include <iostream>using namespace std;/** Returns the factorial of n*/long factorial(int n){if (n == 1)return 1;elsereturn n * factorial(n – 1);}int main(){int n;cout << “Enter a number: “;cin >> n;if (n > 0)cout << n << “!= ” << factorial(n) << endl;elsecout << “Input Error!” << endl;return 0;}

Background image of page 1
 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"