RSS

Monthly Archives: September 2016

Solution of program asked in elluminati

class Program 
{
	public static void main(String args[])
	{
		int n=Integer.parseInt(args[0]);
		int s=0;
		for(int i=1;i<=n;i++)
		{
			s=s+i;
		}
		int d=n-1;
		
		int t=0;
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=i;j++)
			{
				if(j==1)
				{
					t=s;
					s--;
				}
				else
				{
					t=t-d;
					d=d-1;
				}
				System.out.print(t + " ");
			}
			System.out.println("\n");
			d=n-1;
		}
	}
}

program

 
Leave a comment

Posted by on September 28, 2016 in Example