Luigi
ooh i think i understood
Luigi
so a it's like a counter
Luigi
right?
Anonymous
Wait, now that i think of it it might just not work with 2 variables
Anonymous
Wait a second
Luigi
take ur time
Anonymous
Ok, we need to do that with 3 variables
Anonymous
0-0
Anonymous
a,b and?
I'm thinking about how to do that
Anonymous
What do you actually want to do?
Anonymous
He wants to print the fibonacci sequence from 1 to n
Luigi
i want to find a way to have a "Previous number" variable
Anonymous
Not sure what n is
Luigi
its 4 milion
Luigi
i want to find a way to have a "Previous number" variable
and i think i got that, by doing a= a+b, but then b would be everytime 1, and it needs to change ( i did a=2; and b=1;)
Anonymous
^^
klimi
Sum is in b
Good job
Luigi
Sum is in b
i should do a=1 and b=2? i have to start from 1 and 2
Anonymous
Sum is in b
Your choice Just don't put 0 in both lol
Anonymous
b = sum of two numbers a = previous number After one iteration of the loop. Loop it the number of times you want
Luigi
oh so is it with "for"? or i can do it with while?
Luigi
i mean, my loop right now is: while (b<=4000000)
Anonymous
So basically you want to add numbers till the sum reaches 4M!
Anonymous
?
Luigi
yeah and i have to see them in the output
Luigi
i should put the cout in the loop, right?
Luigi
<<cout<<b;
Anonymous
Ye
Luigi
i mean cout<< xD
Luigi
not <<cout
Luigi
i failed
Anonymous
a = 0 b = 1 --- loop start --- b = a+b a = b-a cout << the thing you wanna print -- end loop--
Anonymous
^
Luigi
could you explain me the a = b-a code?
Anonymous
It's MATHS uwu
Luigi
ahah
Luigi
so if a=5 b=7; b=5+7=13 and a= 7-5=2, how could 2 be the previous number ahah
Luigi
The numbers are attached, how can i fix that?
Anonymous
a = 13 - 5 What the heck
Anonymous
-.-
Anonymous
B is updated dub
Luigi
oh right
Anonymous
Duh
Luigi
a= b-a comes after the b= a+b
Luigi
ur right
Luigi
i'm a monkey ahah
Luigi
cout<< b ; this is actually my output code, but the numbers are attached
Luigi
how can i fix it?
Anonymous
xD
Luigi
lmao
Luigi
i'm just tilted from the coding, i'm not that bad ahah dw
Anonymous
xD just jk
Anonymous
Or cout<<b<<endl
Luigi
i don't want to use endl
Luigi
i want to have every number next to it
Luigi
exactly
Anonymous
Just use a single space in between
Anonymous
i want to have every number next to it
Cout<<" "<<b;
Anonymous
?
Anonymous
Ye
Luigi
oh right, "" empty string
Anonymous
oh right, "" empty string
Nu it's a string with a whitespace character ^^
Luigi
oh haha
Luigi
i actually have a problem with this program
Luigi
it gets to 3.5 millions then it sums again
Luigi
and gets over 4 millions
Luigi
then it stops
Anonymous
Because b is less than 4 million
Anonymous
As you requested
Luigi
because the loop sums till B its 4 millions
Luigi
i mean, it's not a problem, regarding to the exercise, right?