title: Recursive method how it wok to print shap
body: <hr>
  
  <p>I want to know how recursive method work to prints a large X composed of smaller X's with a given “width”, input number, which is guaranteed to be odd.</p>
  
  <p>the “width” is length (number) of X’s along one line large X.</p>
  
  <p>Example for an X of width input number =3
  the method will print this shape!</p>
  
  <pre><code> X X
  
    X
  
   X X
  </code></pre>
  
  <p>I try to solve this problem but I couldn't 
  can anyone here help me .. 
  in java code , </p>
  
  <p>This is my code he works good but prints wrong when numberinput=7 or 5</p>
  
  <pre><code> public static String shape(String i,int  numberinput) {   
   //error check, not working for even numbers
   if(numberinput%2 == 0)
      return null;
  
   //terminating condition, stop recursion when this occurs.
   if(numberinput == 1)
      return "X";
  
  else
  
  return "X"+" "+i+"\n" +" "+shape(" "+i,numberinput-2)+" "+"\n"+i+" "+"X";
  }
  </code></pre>
  
  <p>he prints this when numberinput=5</p>
  
  <pre><code>       X X
  
      X  X
  
      X 
  
      X X 
  
      X X
  </code></pre>