We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4634fa3 commit 4ccfe50Copy full SHA for 4ccfe50
Fibonacci Numbers
@@ -0,0 +1,38 @@
1
+# include <iostream>
2
+# include <bits/stdc++.h>
3
+
4
+using namespace std;
5
6
+void input(int &n)
7
+{
8
+ cin>>n;
9
+}
10
11
+void display(int &c)
12
13
+ cout<<c<<" ";
14
15
16
+void fibo(int &n)
17
18
+ int a=0, b=1, c=0;
19
20
+ while(n--)
21
+ {
22
+ display(c);
23
+ a=b;
24
+ b=c;
25
+ c=a+b;
26
+ }
27
28
29
+int main()
30
31
+ int n; //for no. of elements
32
33
+ input(n);
34
35
+ fibo(n);
36
37
+ return 0;
38
0 commit comments