Inverted Right Angle Triangle Pattern

Let us see the logic of famous interview pattern – Inverted Right Angle Triangle.

public class Tech4Humans {

	public static void main(String[] args) {

		// length of triangle
		int size = 5;

		for (int i = 0; i < size; i++) {
			for (int j = 0; j < size-i; j++) {
				System.out.print("* ");
			}
			System.out.println();
		}

	}

}

* * * * * 
* * * * 
* * * 
* * 
* 

The above code can be easily debug. To understand simple way to debug code visit RIGHT WAY TO DEBUG CODE USING PEN AND PAPER.

Leave a Comment