You need to pick a number that's a power of 2 for N: 4, 8, 16, 32, 64, 128, etc. or you need to do fractional doubling here:
int intlg2N = (int)lg2N;
for(int i=0;i< intlg2N;i++){
Let's work through this. The log2 (10) is 3.3219. But you're rounding to 3.
So you're getting 2 * 2 * 2.