How's the result to this 7?
void foo(int i){
if(i>1){foo(i/2);foo(i/2);}cout<<"#"<<endl;}
Jump to Postyou've written a broken code.
Please change & clarify the code.
you've written a broken code.
Please change & clarify the code.
Putting it in a readable form:
void foo(int i)
{
if(i>1)
{
foo(i/2);
foo(i/2);
}
cout<<"#"<<endl;
}
I don't see where a 7 results, regardless of input. This function doesn't really do anything other than waste time and memory.
What's your real question?
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.