Segmentation fault in my code

why there is a segmentation fault in my code ?

There are 2 obvious errors. First you aren’t taking modulo, so the answer will be very large and you won’t be able to store it, hence the segmentation fault. Second being you need to use dp, to store the answers to avoid TLE. Your recursion equations are correct. You can see this code for reference

segmentation fault , after taking the modulo. can you help to fix it please

Did you use dp this time?

no i do not use dp . But I think if dp is the problem then then should be tle , not segmentation fault

Please share the new code.

I didn’t see carefully, your recursion conditions were also wrong. Here is your code with tle

Apart from that you weren’t taking m as input here. Your syntax is wrong.

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.