title: Create an array with first x happy numbers
body: <p>I would like to create an array that contains the first x happy numbers.</p>
  <blockquote>
  <p>A happy number can be defined as a number which will yield 1 when it is replaced by the sum of the square of its digits repeatedly. If this process results in an endless cycle of numbers containing 4, then the number is called an unhappy number.</p>
  </blockquote>
  <p>I have managed to write two functions: one to sum the squared digits and one to check if a number is happy:</p>
  <pre><code>public static int sumDigitSquare(int n) {
      if(n &lt; 10)
          return (int) (Math.pow(n,2));
  
      return (int) (Math.pow((n%10),2)) + sumDigitSquare(n/10);
  }
  
  public static boolean isHappy(int n) {
      int res = sumDigitSquare(n);
  
      while(res != 1 &amp;&amp; res != 4) {
          res = sumDigitSquare(res);  
      }
  
      if(res == 1) 
          return true;
  
      return false;
  }
  </code></pre>
  <p>Now I would like to add a function <code>public static int[] happyArray(int x)</code>
  which returns the first x happy numbers as an array, but I am not sure how to make this happen.</p>