Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

fibonacci sequence c++

#include <bits/stdc++.h> 
using namespace std ;
int main (){
             int n,p1=0,p2=1,d;
             cin>>n;

             for( ;0<n;n--){
                cout<<p1<<" ";
                 d=p1;
                p1+=p2;    
                p2=d;
             
             }
             return 0;
}
Source by www.codegrepper.com #
 
PREVIOUS NEXT
Tagged: #fibonacci #sequence
ADD COMMENT
Topic
Name
2+1 =