+ 1
C++ / pow
Hi guys ! In C++ , How can I find the summation of a number powered from 1 to (n) ... I mean like the sum of : (2^1)+(2^2)+....+(2^n) Let n=3 so that our result should be = 13
1 Resposta
+ 2
Hey ONeal Brown this is a great question
You have to use a header file math.h and then use pow keyword in the loop(for loop) and place a format in it.
Like
a+=pow(2,i) where i is the variable use in for loop.