Write a algorithm generate the following series: 1, 3, 7, 15, 31, 63, 127,……
….. for n terms where n>0.
Answers
Answered by
0
every second number is got by multiplying it by two times of the number & adding it to previous number. For eg: the difference between 1 & 3 is 2. So the next number 7 is got by multiplying the diff with 2 & adding it to previous number, which is 3+2*2=7. Similarly it goes on like 7+4*2=15, 15+8*2=31, 31+16*2=63 & finally 63+32*3=127.
Similar questions