C programming | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

C programming

8. Write a C program to calculate a series of fractions as shown below: Sn=1/n+1/(n-1)+1/(n-2)+...+1

22nd Jul 2018, 9:31 AM
Tony Cyril
Tony Cyril - avatar
2 Answers
+ 1
please try with recursive function.... recursive function should have base case for sure which is n==1 and return 1
22nd Jul 2018, 9:54 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 1
this is pretty simple if you ask me, just make a for loop that iterates from n to 1 and add 1/i to a sum number
22nd Jul 2018, 11:57 AM
hinanawi - avatar