I have an array A = [1,2,3] I need to find the array B[i] with the below statement. calculation i did:
B[0] = A[1] + F[0]
1 + F[0] = 1+0=2 hence B=[1]
1 + F[1] = 1+2=3 hence B=[1,2]
1 + F[2] = 1+3=4 hence B=[1,3,4] but the ans is [1,3,5] how?
0
F[0] = Σ A[2 * (0/2)] = A[0]=0 since array A is 1 based index
j=2
1
F[1] = Σ A[2 * (1/2)] = A[1]= 2
j=2
2
F[2] = Σ A[2 * (2/2)] = A[2]= 2
j=2
B[i] = A[1] + F[i]
F[i] = 0,1 <= i < k
i
F[i] = Σ A[k * (j/k)]
j=k
where A=[1,2,3] // 1 based index
k=2
what is the value of B
Asked
Active
Viewed 26 times
0
-
F[1] = 0 because 1 < k. F[2] = A[2] = 2. F[3] = A[2]+A[3] = 5. B[1] = A[1]+F[1] = 1, B[2] = A[1] + F[2] = 3. B[3] = A[1] + F[3] = 6. – Ivan Kaznacheyeu Mar 12 '22 at 13:47
-
My first comment may be wrong. In computer arithmetic (3/2) can be equal to 1, then F[3]=A[2]+A[2]=4, B[3]=A[1]+F[3]=5. – Ivan Kaznacheyeu Mar 12 '22 at 14:54
-
F[i] = 0,1 <= i < k I did not get this part – Dunder Mifflin Mar 12 '22 at 18:03