Number Pattern:
Here in this pattern printing, the number of lines of the pattern is taken as the input. Two for loops are used to display the pattern. The first for loop (the outer for loop) is used to count the line number so the loop is from 1 to n. for ith line number of elements is i. for each line the difference of first two elements are n-1, the difference between 2nd and the 3rd element is n-2 and so on.
INPUT: the number of lines
OUTPUT: the aforesaid pattern
PROCESS:
Step 1: read n [the number of lines]
Step 2: for i=1 to n repeat
Set a<-n
Set k<-i
For j=1 to i repeat
Print k
Set a<-a-1
Set k<-k+a
[End of ‘for’ loop]
Move to the next line
[End of ‘for’ loop]
Step 3: stop.
for(i=1;i<=n;i++)------------------------------------------------ n
{ a=n;
for(k=i,j=1;j<=i;j++,k+=a)------------ i
{ printf("%d ",k);
a--; }
printf("\n");
}
The complexity is: O(n*i)=O()
Contributed by