Formation of autonomous mobile robots to an arbitrary geometric pattern in a distributed fashion is a fundamental problem in formation control. This paper presents a new fully distributed, memoryless (oblivious) algorithm to the formation control problem via distributed optimization techniques. The optimization minimizes an appropriately defined difference function between the current robot distribution and target geometric pattern. The optimization processes are performed independently by individual robots in their local coordinate system. A movement strategy derived from the results of the distributed optimizations guarantees that every movement makes the current robot configuration approaches the target geometric pattern until the final pattern is reached.