patternprogram_56 softethics

Pattern 56

C

/*

Interesting fact about this pattern :-

The last value(bottom-right corner) of the pattern is equal
              to the sum of all numbers from 1 to n.

e.g.

1
2 6
3 7 10
4 8 11 13
5 9 12 14 15


last value is 15, which is equal to 1+2+3+4+5

*/


#include<stdio.h>

int main()
{

  int n=10;// size

  int i,j,k;

  for(i=1; i<=n; i++)
  {
    k = i;

    for(j=1; j<=i; j++)
    {
      printf("%2d ",k);
      k=k+(n-j);
    }
    printf("\n");
  }

}

C++

Java

C#

Python

0 0 votes
Rate this Program
Subscribe
Notify of
guest


0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments