0
Why is output 1-2-4-7-11 instead of 1-2-4-8-16?
5 Réponses
+ 2
Тимур Завьялов
arr[i] = arr[i-1]+i;
For i=3
arr[3] = arr[2] + 3
=> 4 + 3 { as arr[2] is 4 as calculated above }
Similar is the case of arr[4]
I am curious to know how are you calculating it to be 8 and 16 ?
+ 7
arr[0] = 1 { initialization }
arr[1] = arr[0] + 1 => 1+1 = 2
arr[2] = arr[1] + 2 => 2+2 = 4
arr[3] = arr[2] + 3 => 4+3 = 7
arr[4] = arr[3] + 4 => 7+4 = 11
+ 1
Arsenic, thank you, I got it)
0
Do dry run and put values one by on write values on copy u will understood self
0
Arsenic, can you explain me why 4+3 and 7+4?