Hi, was wondering if there's a more mathematical approach to calculating a sequence of numbers where each number multiplies itself by 2. so starting with the number 5, and running 6 levels you would end up with
5, 10, 20, 40, 80, 160
I've got this and it works, but wondering if there's a more efficient way of doing it?
int n = 5;
int level = 6;
for (int i = 1; i < level; i++) {
n *= 2;
}
return n;
thanks