V
V
Vlad2422018-10-09 19:25:42
C++ / C#
Vlad242, 2018-10-09 19:25:42

Can you please explain the code in detail?

I have this code, can you tell me what it does

if(number <= 0) return 1;
  double multi_factor = 1;
  std::cout << std::endl;
  while((buffer = number * multi_factor) >= 1){
    std::cout << buffer << " ";
    multi_factor /= 2;
    if(buffer % 2 != 0) break;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
1
15432, 2018-10-09
@Vlad242

At the input we have some number. The specified code divides this number in half until it becomes odd. And at each step displays the result. But it looks wildly inefficient, maybe I'm wrong.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question