WRTE A PROGRAMME THAT ID USED TO FIND THE ALL NUMBER WHICH ARE MISSING IN A FIBONACII SERIES: solution: #include <bits/stdc++.h...
WRTE A PROGRAMME THAT ID USED TO FIND THE ALL NUMBER WHICH ARE MISSING IN A FIBONACII SERIES:
solution:
#include <bits/stdc++.h>
using namespace std ;
int fibo(int n){
if(n==1 || n==0) return n;
return fibo(n-1)+fibo(n-2);
}
int main(){
int n ;cin>>n;
vector<bool> vis(n+1,false);
int last_n = fibo(n-1);
for(int i = 0 ; i<n ;++i){
for( int j = 0 ; j<last_n ; ++j){
if(fibo(i) == j){
vis[j] = true;
}
else {
continue;
}
}
}
for( int i = 0 ; i<last_n ;++i){
if(!vis[i]){
cout<<i<<" ";
}
}
}
input : 10
output :
ikash@vikash-HP-Laptop-15-da0xxx:~/Desktop/competative_coding$ g++ a.cpp -o a
vikash@vikash-HP-Laptop-15-da0xxx:~/Desktop/competative_coding$ ./a
10
4 6 7 9 10 11 12 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 vikash@vikash-HP-Laptop-15-da0xxx:~/Desktop/competative_coding$
video tutorial for better understanding :