Von Neuman Loves Binary problem


using namespace std;

int main() {

int N, sum, numb, rem, base, I;




	sum = 0;

	while( numb != 0){

		base = 0;

		rem = numb % 10;

		if (rem == 1){

			sum = sum + (2 * base);


		base *=2;

		numb = numb /10;




return 0;


What’s wrong with the code?

hello @omkarvp99

pls save ur code here->

and share its link with me

1 Like

Oh got it. I was asking for the same.

Here’s the link to code.

check now->

1 Like

And what about the logic, is it efficient to use or not?
What’s the efficient logic to apply, any other?

yeah it is the most efficient logic.

1 Like

@aman212yadav, Thank you.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.