title: Print star pattern using equation of straight line
body: <p>I want to print the following pattern:</p>
  
  <pre>
      *
     **
    ***
   ****
  *****
  </pre>
  
  <p>I know the equation will be <code>x+y&lt;=5</code>. For this equation we have to print <code>*</code>, but I can't get the <code>for</code> loop conditions.
  Please help.
  Edit: Here is the code I wrote:</p>
  
  <pre><code>public class Pattern{
  public static void main(String[] args){
      for(int i = 1; i &lt;= 5; i++)
      {
          for(int j = 1; j &lt;=5; j++)
              System.out.print((-i+j)&lt;=5 ? "*" : " ");
          System.out.println("");
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>The equation for the pattern in terms of a straight line in the 2nd quadrant will be y-x&lt;=5. But the conditions in the for loop do not satisfy.</p>