How is x ever going to equal 3 when your for loop breaks on x<3? Start there.

What is the undesired effect you are getting right now? That would help us hunt down your problem.