Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 1 + 1/2 + 1/3 ........ 1/n
- // Date : 06.10.19
- #include<stdio.h>
- int main(){
- int n;
- printf("Enter the range of series: ");
- scanf("%d", &n);
- printf("The series is: 1 + ");
- float sum = 1;
- for(int i = 2; i<= n; i++){
- printf("1/%d ", i);
- sum = sum + (1.0/i);
- if(i != n) printf("+ ");
- }
- printf(" = %f", sum);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement