Phil67rpg, I have a question: Why not just solve the problem?
I mean this very seriously: In almost all of your posts, you ask a question which you could probably solve if you actually tried. Rather than trying, however, you always just try to Google the answer and then ask us for a "hint". You're never going to learn to code properly unless you bang your head against the wall enough to where you can actually solve problems. The whole idea of computer science is solving problems using a computer.
Also, if you really want the answer: Here is is ! (I highly recommend you solve the problem yourself. My code is uncommented about how the solution works for your benefit.
Cheers !
(Read below for a full solution.)
Okay, so look at this:
(- is a space)
---x
--xxx
-xxxxx
xxxxxxx
If we look at the above code, we notice that for every row of X's we decrease the amount of spaces on the left by one. If we know that, it's trivial to write a for loop which will print the necessary amount of spaces depending on what the first amount of spaces we printed was.
So how do we figure out the first amount of spaces (by first amount of spaces I mean the spaces before the first x printed)?
Well, if we look we notice that the first amount of spaces is the same amount on each row of the first x. So, all we need to do is figure out the "middle" of the amount of x's we print on the last line:
If we look at the above diagram, we notice that X1 and X2 are the same. Which means that the first amount of spaces is equal to one less than the maximum amount of x's we print divided by two:
So, we just need to find X3 (Which is equal to the amountOfLoops variable I created in the ideone code above), then apply the equation above, and plug the equation inside a for loop before we print x.