+ 2
If it's really about these two series, it should be simple, as h and v are very similar and both are almost an exponential function... h is 0, 2^0, 2^1, 2^2, ... and so on... v is 2^1, 2^1, 2^2, ... A loop could look similar to this: unsigned int ans = 1; for(unsigned int i=0; i<n; ++i) { ans = ans * 2; } It's an intentionally incomplete answer for both cases but you are already 95% there. This way you still learn from the example.
17th Jul 2016, 9:38 AM
Stefan
Stefan - avatar