0

[C language] What's wrong with my code? Help me, please. I already try for 9 times and the online judge still say wrong answer.

Bibi is learning about recursive. As she was browsing online, she found a particular recursive equation Tn = 2 × T(n−1) + 3 × T(n−2). Bibi is curious of what the result of Tn will be given n. Help Bibi given T0 = 1 and T1 = 1 ! Format Input The only line of input contains n. Format Output The output of this problem will be Tn . Constraints • 1 ≤ n ≤ 30 Sample Input (standard input) 5 Sample Output (standard output) 121 https://code.sololearn.com/czAWN014zZVN/?ref=app

21st Nov 2020, 6:59 AM
Briana
Briana - avatar
2 odpowiedzi
+ 5
For values of 'n' > 21 the integer variable will overflow due to numbers becoming too large. Since 'n' must be positive given the restraints, try using unsigned int or even unsigned long long instead of int in your program, that should be enough to store values up to at least values of 'n' <= 30. Don't forget to change the format specifiers as well. Does that make it work?
21st Nov 2020, 11:00 AM
Shadow
Shadow - avatar
0
Shadow yes.. It's work. Thankyou so muchh
21st Nov 2020, 1:16 PM
Briana
Briana - avatar