0

What is the formula?

// sequence of number 1,3,7,15,31,63,127... Write a program with recursive function. When user enter 6 display 63.

23rd Apr 2020, 5:09 PM
Kyrene
3 Answers
0
Whar you tried so far..? Did you find logic..?
23rd Apr 2020, 5:39 PM
Jayakrishna 🇼🇳
0
u[1] = 1 u[i] = u[i-1]*2 + 1 so: u[2] = 1*2 + 1 => 3 u[3] = 3*2 + 1 => 7 u[4] = 7*2 + 1 => 15 u[5] = 15*2 + 1 => 31 u[6] = 31*2 + 1 => 63 ... or, in a non recursive way: u[i] = 2^i - 1 (where ^ is the power operator)
25th Apr 2020, 5:19 AM
visph
visph - avatar
0
Ok~thank you very much
25th Apr 2020, 11:22 AM
Kyrene