title: How can i loop this process more effectively
body: <p>I have written a little script to automate some calculations for me. It is pretty simple. 
  1*3=3
  2*3=6
  3*3=9 and so on. When the answer(product) is more than one digit long I want it to add the digits of the answer.
  3*4=12 || 1+2=3. 
  I want it to automatically add the answer if it is more than one digit no matter how many times  adding the answer arrives larger than a single digit.
  as in when you reach 13*3=39 || 3+9=12 || 1+2=3 
  Currently my code does not loop, and i cannot figure out how to make it loop here.</p>
  
  <p><a href="http://screencast.com/t/MdpQ9XEz" rel="nofollow">http://screencast.com/t/MdpQ9XEz</a></p>
  
  <p>Also, it is not adding up more than 2 digit answers see 34*3=102. any help here to allow it infinity addition would be great.
  As each line is produced the answers get larger, so it should add as many digits there are in the answer.</p>
  
  <p>here is my code:</p>
  
  <pre><code>$i = 1; //Start with one
  function count_digit($number) {
      return strlen((string) $number);
  };
   while($i &lt; 500){
      $product = $i * 3; //Multiply set
      $number_of_digits = count_digit($product); //calls function to count digits of $sum
  
          if($number_of_digits &gt; 1){  //if $sum has more than one digit add the digits together
          $addproduct = strval($product);//seperates the digits of $sum
          $ii = 0;
  
          while($ii &lt;= $number_of_digits -1){
              $io = $ii + 1;
              if($io &lt; $number_of_digits){
                  $one = intval($addproduct[$ii]);
                  $two = intval($addproduct[$io]);
                  $sum = $one + $two;
                  print($i . ' * 3 = ' .$product. ' || ' .$one. ' + ' .$two. ' = ' .$sum. '&lt;br&gt;');
              };$ii++;
          };
  
      }else{
          Print ($i . ' * 3 = ' .$product.'&lt;br&gt;'); //Print Set
      };
  $i++; //add one
  </code></pre>
  
  <p>}</p>