In time-critical multi-agent tasks, it is important for the agents to reach consensus as fast as possible. In this paper, we consider the problem of computing the weights in the weighted-average consensus protocol that achieve average consensus with an optimal per-step convergence factor. Most of the work in the literature either computes these optimal set of weights in a centralized manner, which requires global information about the network that may not be available, or computes a suboptimal set of weights, which are slow in achieving consensus. We propose an iterative, distributed algorithm to compute a set of weights that achieve an optimal convergence factor. We give theoretical guarantees of the convergence of the algorithm. Through numerical examples, we show that our method performs better than other distributed methods of computing weights for consensus, and it matches the performance of the centralized optimal method.