# Thread: Logic needed for buiding numbers pyramid

1. ## Logic needed for buiding numbers pyramid

Code:
```     1
121
12321
1234321
123454321```
EDIT:
the above pyramid looks like a doom.i.e 1-5 will be in center.1-4(L)1-3(L)1-2(L)1(L) similarly 1-4(R) 1-3(R) 1-2(R) 1(R)

I'm partly successful in building the requirement of the program.but cant able to think the logic for the other half.please tell me how can i proceed.below is the code written in c#.

Code:
```            for (int i = 1; i <= 5; i++)
{
//int l = 1;
int k = 1;
for (int j = 5; j >=1; j--)
{
if (j > i)
{
Console.Write(" ");
}
else
{
Console.Write(k++);
}

}

Console.WriteLine();

}```

2. Code:
```    1
1
1
1
1```
Ok. If your number is 5, then you have 5-centernumber spaces to the left (and to the right)

So you write out that many space.
Then you write numbers from 1 to centernumber-1.
Then you write the center number.
Then you write numbers from centernumber-1 to 1.

All of that is one line. For each line from 1 to number, do all of that, and at the start of the next line, increment the center number.

Quzah.

3. Originally Posted by quzah
Code:
```    1
1
1
1
1```
Ok. If your number is 5, then you have 5-centernumber spaces to the left (and to the right)

So you write out that many space.
Then you write numbers from 1 to centernumber-1.
Then you write the center number.
Then you write numbers from centernumber-1 to 1.

All of that is one line. For each line from 1 to number, do all of that, and at the start of the next line, increment the center number.

Quzah.
thanks for the response.i'll try this.

4. I have a formular, that doesn't need to count for each number. (it means if you know n lines: line i like y_coor, at line i, j(th) like x_coor, so I know what number at coordinate(x,y). But maybe It is not nescessary. Here is my straightforward code same with quxah idea:
Code:
```namespace Program
{
class Program
{
static void Main(string[] args)
{
// print triangle
int n = 5;
/* three phrase:
* first: find first location of the line
* second: print increasing
* third: print decreasing */
int k=n;
for (int i = 0; i <n; i++)  //print n line
{
//  first
for (int j = 1; j <= k; j++) Console.Write(" ");
// second
for (int j = 1; j <= i; j++) Console.Write(j);
// third
for (int j = i + 1; j >= 1; j--) Console.Write(j);
k--;
Console.WriteLine();
}

}
}
}```

@: Oh, I'm sorry, the lastest post has appeared last week. I just post a new one because I just want to practice C# code.