title: In Java finding numbers that are both a Triangle Number and a Star Number
body: <p>This is the question I've been assigned:</p>
  
  <blockquote>
    <p>A so-called “star number”, s, is a number defined by the formula: 
    s = 6n(n-1) + 1 
    where n is the index of the star number. 
        Thus the first six (i.e. for n = 1, 2, 3, 4, 5 and 6) star numbers are: 1, 13, 37,
     73, 121, 181</p>
    
    <p>In contrast a so-called “triangle number”, t, is the sum of the numbers from 1 to n: t = 1 + 2 + … + (n-1) + n. 
    Thus the first six (i.e. for n = 1, 2, 3, 4, 5 and 6) triangle numbers are:  1, 3, 6, 10, 15, 21</p>
    
    <p>Write a Java application that produces a list of all the values of type int that are both star number and triangle numbers.</p>
    
    <p>When solving this problem you MUST write and use at least one function (such as <code>isTriangeNumber()</code> or <code>isStarNumber()</code> 
    or <code>determineTriangeNumber()</code> or <code>determineStarNumber()</code>).  Also you MUST only use the formulas provided here to solve the problem.</p>
  </blockquote>
  
  <p>tl;dr: Need to output values that are both Star Numbers and Triangle Numbers.</p>
  
  <p>Unfortunately, I can only get the result to output the value '1' in an endless loop, even though I am incrementing by 1 in the while loop.</p>
  
  <pre><code>public class TriangularStars {
      public static void main(String[] args) {
  
      int n=1;            
      int starNumber = starNumber(n);
      int triangleNumber = triangleNumber(n);
  
      while ((starNumber&lt;Integer.MAX_VALUE)&amp;&amp;(n&lt;=Integer.MAX_VALUE))
      {
          if ((starNumber==triangleNumber)&amp;&amp; (starNumber&lt;Integer.MAX_VALUE))
                  {
                      System.out.println(starNumber);
                  }
          n++;
      }
    }
  
  
  public static int starNumber( int n)
  {
      int starNumber;
      starNumber= (((6*n)*(n-1))+1);
      return starNumber;
  
  }
  public static int triangleNumber( int n)
  {
      int triangleNumber;
      triangleNumber =+ n;
      return triangleNumber;
  }
  </code></pre>
  
  <p>}</p>