0

How did i write this formula 2*n-1 in recursive function?

23rd Apr 2020, 7:06 AM
Kyrene
4 Respostas
0
func(int n) { If(n==0) return 1; return 2*func(n-1); } //Something like this
23rd Apr 2020, 10:33 AM
Aditya Agrawal
Aditya Agrawal - avatar
0
I using this method when i enter 2 , output not 3
23rd Apr 2020, 10:40 AM
Kyrene
0
You are asking for power right? 2 (raised to the power) n-1
23rd Apr 2020, 10:42 AM
Aditya Agrawal
Aditya Agrawal - avatar
0
My question is like this 1,3,7,15,31,63 when i enter 6 it will display 63
23rd Apr 2020, 10:48 AM
Kyrene