I am getting the right answer after successful compilation code but it is showing that testcases are failing

#include
using namespace std;
int assign(int num){
if( num == 1){
return 2;
}
if( num == 2 ){
return 3;
}
return assign( num - 1) + assign( num -2);
}
int main() {
int n;
cin >> n;
int num;
for( int i = 0; i < n; i++){
cin >> num;
cout << β€œ#” << num <<" : "<< assign(num) << endl;
}
return 0;
}

hi @akki56756_bab14f919dbad123

cout << β€œ#” << num <<" : "<< assign(num) << endl;

here instead of printing num, print the iteration no…
I have corrected your code… its working fine now–>

hi @akki56756_bab14f919dbad123
I hope its clear now??

yeah , its working fine

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.