I have some troubles finding the right logarithm for my app. I have an array in which I would like to put some numbers (place-numbers). These numbers depend on the value of a variable (always an exponent of 2) that is given. The number of total places (pl) is also know.
The number before the place should be the array-index. The place should be the content of the array item.
I already tryed using a recursive function, but without success. Difficulty is that the odd numbers have to stay on top.
The number before the place should be the array-index. The place should be the content of the array item.
I already tryed using a recursive function, but without success. Difficulty is that the odd numbers have to stay on top.
Code:
----2---- ----4---- ----8---- ----16----
1 (pl.01) 1 (pl.01) 1 (pl.01) 1 (pl.01)
2 (pl.08) 3 (pl.05) 5 (pl.05) 9 (pl.05)
4 (pl.12) 3 (pl.09) 5 (pl.09)
2 (pl.16) 7 (pl.13) 11 (pl.13)
8 (pl.20) 3 (pl.17)
4 (pl.24) 13 (pl.21)
6 (pl.28) 7 (pl.25)
2 (pl.32) 15 (pl.29)
16 (pl.36)
8 (pl.40)
14 (pl.44)
4 (pl.48)
12 (pl.52)
6 (pl.56)
10 (pl.60)
2 (pl.64)
my last attempt :
Dim ARpos() As Integer
Msg = "Total array items :"
AR = InputBox(Msg)
ReDim ARpos(AR)
i = 0
j = AR
Do
i = i + 1
k = 2 ^ i
If i Mod 2 = 0 Then
ARpos(i) = Places / AR * j 'lower half
j = j - 1
Else
ARpos(i) = ((Places / 2) / AR * i) - 1 'upper half
End If
Loop Until k = Places
Msg = "Places : " & vbCrLf
For i = 1 To AR
Msg = Msg & i & " : " & ARpos(i) & vbCrLf
Next
MsgBox Msg
[\code]
This works fine for the 4 places column, but not for the others.