The question of whether foraging swarms can form as a result of a noncooperative game played by individuals is shown here to have an affirmative answer. A dynamic game played by N agents in 1-D motion is introduced and models, for instance, a foraging ant colony. Each agent controls its velocity to minimize its total work done in a finite time interval. The game is shown to have a unique Nash equilibrium under two different foraging location specifications, and both equilibria display many features of a foraging swarm behavior observed in biological swarms. Explicit expressions are derived for pairwise distances between individuals of the swarm, swarm size, and swarm center location during foraging.