Oct 31, 2017 at 11:12pm
hello, you should note that ^ doesn't mean "power" in c++, you should use
std::pow(2,n)
in cmath.
Also it's simpler to store the value of an expression in a varible and use it in a condition rather than compute it every time in your loop.
1 2 3
|
int variable = std::pow(2,n) -1;
//use variable in your loop.
|
Last edited on Oct 31, 2017 at 11:13pm