title: How do I go about figuring out this complicated recursion algorithm?
body: <p>I just started Data Structures and Algorithms which is taught in Java. So far I've only learned C++ in my life so I'm still VERY new to using java.</p>
  
  <p>Anyways I have a homework problem I'm a little stuck on:</p>
  
  <p>Write a recursive method that returns the number of 1's in the binary representation of N. Use the fact that this is equal to the number of 1's in the representation of N/2 + 1, if N is odd.</p>
  
  <p>Now i'm not sure how exactly to do this. I already have a function set up that takes an integer and converts it to binary and stores it in a string, yet the rest I'm kinda lost on.</p>
  
  <p>If I can get some guidance, that would really help.</p>
  
  <p>This is what I have so far:</p>
  
  <pre><code>import java.io.*;
  public class Homework1Code {
    static void prtbinary(String Molly, int size){
      if(size &lt;=0){
        return;
      }
    }
  
    public static void main(String[] args) {
      int i = 38;
      String binstr = Integer.toBinaryString(i);
      System.out.println("The Original Decimal Number is: " + binstr);
      prtbinary(binstr, binstr.length());
    }
  }
  </code></pre>
  
  <p>Thanks</p>