Skip to content

Instantly share code, notes, and snippets.

@twopoint718
Created June 20, 2009 01:47
Show Gist options
  • Select an option

  • Save twopoint718/132995 to your computer and use it in GitHub Desktop.

Select an option

Save twopoint718/132995 to your computer and use it in GitHub Desktop.
multiplication table in python
import math
def multtab(n):
width = 1 + int(math.ceil(math.log(n)/math.log(10)))
format_str = '%' + str(width) + "d"
for row in range(1,n+1):
for col in range(1,n+1):
print format_str % (row * col),
print
if __name__ == "__main__":
multtab(9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment