1#include <iostream>
2using namespace std;
3
4int main(){
5 int a{0},b{1},count{},c{};
6 cin >> count;
7 for (int i = 0; i < count; ++i)
8 {
9 cout << a << endl;
10 c = b;
11 b = a + b;
12 a = c;
13 }
14}
1#include <iostream>
2using namespace std;
3
4int main ()
5{
6 int num1, num2, num3, input;
7 num1 = 0;
8 num2 = 1;
9 cout << "How many nums in sequence do you want to see: ";
10 cin >> input;
11 cout << num1 << " " << num2 << " ";
12
13 for(int i = 2; i < input; i++) // runs through every element but first two
14 {
15 num3 = num1 + num2;
16 cout << num3 << " ";
17 num1 = num2;
18 num2 = num3;
19 }
20
21 return 0;
22}
1#include<iostream>
2using namespace std;
3int main()
4{
5 int num,num1=0,num2=1,num3,i=0;
6 cout<<"enter the number num"<<endl;
7 cin>>num;
8 for(i=1;i<=num;i++)
9 {
10 num3=num1+num2;
11 num1=num2;
12 num2=num3;
13 cout<<num3<<endl;
14 }
15
16}
17
1#include <iostream>
2using namespace std;
3void main()
4{
5 int num,x=0,y=1,fib=0;
6 cin >> num;
7 if (num == 1)
8 cout << "0";
9 else if (num == 2)
10 cout << "0 1";
11 else
12 {
13 cout << "0 1 ";
14 for (size_t i = 0; i < num - 2; i++)
15 {
16 fib = x + y;
17 x = y;
18 y = fib;
19 cout << fib << " ";
20
21 }
22 }
23}
1#include <iostream>
2using namespace std;
3
4int main()
5{
6 int n, t1 = 0, t2 = 1, nextTerm = 0;
7
8 cout << "Enter the number of terms: ";
9 cin >> n;
10
11 cout << "Fibonacci Series: ";
12
13 for (int i = 1; i <= n; ++i)
14 {
15 // Prints the first two terms.
16 if(i == 1)
17 {
18 cout << " " << t1;
19 continue;
20 }
21 if(i == 2)
22 {
23 cout << t2 << " ";
24 continue;
25 }
26 nextTerm = t1 + t2;
27 t1 = t2;
28 t2 = nextTerm;
29
30 cout << nextTerm << " ";
31 }
32 return 0;
33}
34