0

How would I code something like this

N is argument int H is also a unknown number So I’m looking for something like this Let n=z If z == 0 return H Else if z == 1 return H = H * 2 || z = z - 1 While z => 2 return H = H * 2 + 1 || z= z - 2

18th May 2018, 6:01 AM
Wayne Walgenbach
Wayne Walgenbach - avatar
3 Answers
+ 1
int n = z; if(z == 0){ // or if(!z){ return H; }else if(z == 1){ return (H = H * 2) || (z = z - 1); } while( z >= 2 ){ return (H = H * 2 + 1) || (z = z - 2); } But your code seems all over the place :/
21st May 2018, 7:36 AM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
0
H= H * 2 and z - - - Maybe ???
18th May 2018, 6:04 AM
Wayne Walgenbach
Wayne Walgenbach - avatar
0
While z => 2 Return ( H = H * 2 + 1 and z - - - or z - 2 Else if z ==1 Return H = H * 2 Else return H
18th May 2018, 6:08 AM
Wayne Walgenbach
Wayne Walgenbach - avatar