+ 2

Can any tell me the logic to find sum of this series 1+1÷2+1÷3+1÷4......+n and to print this series 1,1,2,3,5,8,13 in c language

14th Mar 2017, 1:26 PM
Stylish Kuri
3 Respostas
+ 2
well i have found it now i was preparing for my test so i wanted not to waste my time
14th Mar 2017, 1:44 PM
Stylish Kuri
+ 2
For series 1,1,2,3,5,8,13 int main (){ int a =0, b=1, c=0; int limit; printf ("Enter limit: "); scanf ("%d", &limit); printf ("%d ", b); while(c < limit){ c=a+b; printf ("%d ", c); a=b; b=c; } }
14th Mar 2017, 4:40 PM
देवेंद्र महाजन (Devender)
देवेंद्र महाजन (Devender) - avatar
+ 1
For 1+1÷2+1÷3+1÷4......+n int main (){ int i, n; cin>>n; float s=1.0; for(i=1;i <=n;i++){ s += float (i)/i; } cout <<s; }
14th Mar 2017, 4:32 PM
देवेंद्र महाजन (Devender)
देवेंद्र महाजन (Devender) - avatar