0
Fibonaci numbers with loop( not recursion)
Can you show me the loop only which show till Nth fibonaci numbers
6 odpowiedzi
+ 15
//why don't you try yourself
https://www.sololearn.com/Discuss/1035209/?ref=app
+ 11
https://code.sololearn.com/c6ErdwUmKLPK/?ref=app
+ 5
#include <iostream>
int main(){
int n1=0,n2=1,indexTo=20;
while(indexTo--){
std::cout<<n1<<"\n";
n1+=n2;
n1^=n2;
n2^=n1;
n1^=n2;
}
return 0;
}
//^= there for swap n1 and n2
+ 3
@Gaurav actually fibonacci is part of my program. Answer you provided was modified by me, So i'm not so dumb to copy and paste your answer. Just couldn't think of algorithm, we are all humans after all. It happens. ANYWAY. THANK YOU, helped me a lot
+ 3
//here is my code
https://code.sololearn.com/c22rEcgbpmXi
+ 2
Couldn't