Review my code or send me the right code

#include

// Recursive function to find number of ways to fill a n x 4 matrix
// with 1 x 4 tiles
int totalWays(int n)
{
// base cases
if (n < 1)
return 0;

if (n < 4)
	return 1;

if (n == 4)
	return 2;

// combine results of placing a tile horizontally and
// placing 4 tiles vertically
return totalWays(n - 1) + totalWays(n - 4);

}

int main(void)
{
int n ;
cin>>n;

cout<< totalWays(n);

return 0;

}

@tyagikeshav30 what’s the problem you are facing?

1 Like

i just wanted to know that is this a right approach to do that tiles qus or not.

@tyagikeshav30 yes it seems correct

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.