Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- double suma(int n, double x);
- int main()
- {
- int n;
- double s, x;
- do{
- printf("\nUnesite n: ");
- scanf("%d", &n);
- }while(n<1);
- printf("\nUnesite x: ");
- scanf("%lf", &x);
- s = suma(n, x);
- printf("\nSuma = %.4f", s);
- return 0;
- }
- double suma(int n, double x)
- {
- int i, zbir;
- double s,st;
- s=1;
- st=1;
- zbir=0;
- for(i=1;i<n;i++)
- {
- st*=x;
- zbir+=i;
- s+=st/(st + zbir);
- }
- return s;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement