Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- queue<unsigned long long> q;
- void fibo_using_queue(int n){
- q.push(0);
- q.push(1);
- for (int i = 0; i < n; i++){
- unsigned long long a = q.front();q.pop();
- unsigned long long b = q.front();q.pop();
- q.push(b);
- q.push(a + b);
- cout<<a<<endl;
- }
- }
- int main(){
- fibo_using_queue(86);//print first 86 Fibonacci numbers
- }
Add Comment
Please, Sign In to add comment