[Solved] Convert loop into mathematical equation


for loop can be simplifed to

x= (pow(3,n)-1)/2

I have double checked this here:
http://www.wolframalpha.com/input/?i=sum+pow%283%2Ci%29+for+i+from+0+to+%28n-1%29

3

solved Convert loop into mathematical equation