Program to find sum of harmonic series | CPP program to find sum of harmonic series using recursion ; Base condition ; Driven Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; float sum ( float n ) { if ( n < 2 ) return 1 ; else return 1 / n + ( sum ( n - 1 ) ) ; } int main ( ) { cout << ( sum ( 8 ) ) << endl ; cout << ( sum ( 10 ) ) << endl ; return 0 ; }