Eran Meshorer, in Correspondence (“Iran is sixth, not second, in Middle East publication list” Nature 443, 271; 2006), states: “When the number of publications (see http://www.ncbi.nlm.nih.gov/entrez) is corrected for population size, Iran becomes only the sixth in terms of scientific productivity.” However, the scientific productivity of a country is not the number of publications divided by the number of people. To evaluate productivity, one has to account for other important factors, such as publication citations. In addition, the NCBI website is mainly devoted to life-sciences journals and does not cover the main journals in other fields.
We can usually use our common sense to evaluate a country's scientific productivity from what we can observe of its output: an article at http://en.wikipedia.org/wiki/Science_in_Iran gives some background. But if a more systematic approach is desired, it is certain that there is no single formula that can provide a definitive ranking.