java – Does any m? explain how I manage to use this algorithm?

public class binary
{
public static void main (String[] args)
{
// Display the binary representation of n.
int n = Integer.parseInt (args[0])
int power = 1;
while (power <= n / 2)
power * = 2;
// Now, power is the greatest power of 2 <= n.
      while (power > 0)
{
// Start the powers of 2 in descending order.
if (n <power) {System.out.print (0); }
else {System.out.print (1); n - = power; }
power / = 2;
}
System.out.println ();
}
}

This algorithm takes a numeric argument from the user and returns the binary value of the user.
I understand the code and everything, but I would like to know how this algorithm works, because if I had to do it, I would not know how to think / think about it. And if possible, I want to know what other algorithm can do the same thing (go from decimal to binary), explaining how and why it works, how I come / think about this algorithm, step by step.