Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- It calculates the sum of the harmonic series until its n-th term s(n).
- */
- #include <stdio.h>
- int main(){
- int n;
- float s = 0;
- printf("Enter n: ");
- scanf("%d", &n);
- while(n > 0){
- s = s + 1.0/n;
- n = n - 1;
- }
- printf("%f\n", s);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement