title: Given a string, compute recursively (no loops)
body: <p>Given a string, compute recursively (no loops) the number of times lowercase "hi" appears in the string</p>
  
  <p>countHi("xxhixx") -> 1</p>
  
  <p>countHi("xhixhixx") -> 2</p>
  
  <p>countHi("hi") -> 1</p>
  
  <pre><code>public class Tester {
  
      /**
       * @param args
       */
      public static void main(String[] args) {
          // TODO Auto-generated method stub
  
          int count = countHi("xxhixx");
  
  
          System.out.println("countHi: " + count);
  
  
      }
  
      public static int countHi(String s) {
          if (s.length() == 0) {
              return 0;
          }
  
          int spot = s.indexOf("hi");
  
          if(spot &gt; 0)
          {   
              String nextString = s.substring(spot + 2);
              return 1 + countHi(nextString);
          }
          return 1;
  
      }
  }
  </code></pre>