The top number is generated by adding the first two bottom numbers together, adding the next two numbers together (the next two numbers are the second one and the third one in this case), etc. You add all of the totals that you get together, and you add the resulting totals together until you get one number at the top.
A quick way of finding what number would be at the top would be to us this operation (assuming there are three numbers at the bottom and that they are x, y and z):
x + 2y + z = Top Number
Similarly, if there are four bottom numbers that are w, x, y and z; you use this operation:
w + 2x + 2y + z = Top Number
Basically, you double all of the numbers that aren't the first and last numbers because they are used twice in the pyramid. You don't double the first and last numbers because they are used only once.
If you change the numbers in the bottom layer, the top number will change, unless all of the numbers are the same. I have found that you get the highest possible number when the numbers in the bottom row are in ascending or descending order.