+ 4

Using for loops write program to generate fibonacci sequence 1 1 2 3 5 8 1 3 2 1

https://www.sololearn.com/discuss/1035622/?ref=app https://www.sololearn.com/discuss/1038399/?ref=app

30th Jan 2018, 1:00 AM
tolites
5 Respostas
+ 19
I made a pseudo code for your question. Begin f=o s=1 IF f <1 THEN print 1 ELSE WHILE f<8 then ans=f+s f=s f=ans print ans END WHILE END IF END.
30th Jan 2018, 1:58 PM
Chinthana Kavinda
Chinthana Kavinda - avatar
30th Jan 2018, 1:03 AM
LordHill
LordHill - avatar
+ 1
#include <iostream> using namespace std ; int main() { long n,i,a=0,b=1,c; cout<<" enter range"<<endl; cin>>n; cout<<a<<" "<<b<<" "; for(i=1;i<=n;i++) { c=a+b; cout<<c<<" "; a=b; b=c; return 0; }
4th Feb 2018, 12:50 PM
Shivam Saurabh
Shivam Saurabh - avatar
0
https://code.sololearn.com/c2g1JX4oZQCb/?ref=app
2nd Feb 2018, 11:37 PM
Daniel
Daniel - avatar