0

How to create function with 2 parameters to print fibonacci?

I have struggle to create this function to return this fibonacci use looping in c++ 0 1 1 2 3 5 8 13 21 34 55 89

8th Feb 2020, 8:53 AM
Artieady Budiman
Artieady Budiman - avatar
7 odpowiedzi
+ 3
can u write a function that adds two numbers given as parameters?
8th Feb 2020, 9:03 AM
Oma Falk
Oma Falk - avatar
+ 2
let's start by cleaning up the unnecessary cout and cin n & m above
8th Feb 2020, 9:41 AM
BroFar
BroFar - avatar
+ 1
i create this code. please correct me #include <iostream> using namespace std; int main() { int n, m, t1 = 0, t2 = 1, t3 = 0; cout << "eter colom: "; cin >> n; cout << "enter row: "; cin >> m; for(int j=1; j<=3;j++){ for (int i = 1; i <= 4; i++) { if(i == 1) { cout <<" "<< t1; } if(i == 2) { cout << t2<<" "; } t3 = t1 + t2; t1 = t2; t2 = t3; cout << t3 << " "; } cout<<"\n"; } return 0; }
8th Feb 2020, 9:25 AM
Artieady Budiman
Artieady Budiman - avatar
+ 1
a good start👍 now we need it as a fuction
8th Feb 2020, 9:37 AM
Oma Falk
Oma Falk - avatar
0
ok... step by step uf u have the first 2 numbers, which is the next one?
8th Feb 2020, 8:55 AM
Oma Falk
Oma Falk - avatar
0
I still stuck on it 🥴
8th Feb 2020, 9:02 AM
Artieady Budiman
Artieady Budiman - avatar
0
here is my code in Perl - maybe you will understand https://code.sololearn.com/cSB0ZKlT7fMR/?ref=app
8th Feb 2020, 9:20 AM
BroFar
BroFar - avatar