Pattern 9

pattern9

 
public class Pattern9
{
// Coded by : Shahbaz Hashmi
public static void main(String[] args)
{
int n = 9; // number of rows and columns
int k, z;
for(int i = 1; i <= n; i++) { System.out.print(i); if(i>1)
{
k = n-1;
z = i;
for(int j = 2; j <= i; j++) { z = z + k; System.out.print(" "+z+" "); k--; } } System.out.println(); } } }

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *