Compute F(N) error

code is working just fine on laptop but online it repeatedly says time limit exceeded…How can I solve this problem??

Don’t use a loop. Try to make some formula.
N is very large you can’t iterate.

2 Likes

Sir tried making formula and code now ran again fine on laptop but online it shows test case failed(wrong answer)

working on laptop but still not working online

It’s n/2 for even case and (n-1)/2 - n for odd case
Its working for me , try this
https://ide.codingblocks.com/#/s/18284

1 Like

Thanks the main code i was missing was long long n.:smiley:

can you please post the question link.
thank you