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
3 odpowiedzi
+ 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 :/
0
H= H * 2 and z - - - Maybe ???
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