Getting result for particualr input

Mam Im unable to get the pattern for n input.
Can u please tell how to proceed with!

Dry run it for a fixed number like 5,6,7 etc. Then see which values are changing and assign them to variable.

im getting coorect output for n=4 and n=5 but after 5 im getting wrong output.

tell me your logic and i will explain why it is wrong

Sir im able to pass all test cases Successfully. Thank You!