#!/usr/bin/python

# Program to display factorials and test "fact.py".

import fact
import sys
import os
import string

def usage():
	print >>sys.stderr, "This program calculates factorials."
	print >>sys.stderr
	print >>sys.stderr, "Usage: %s expression_or_numbers" % os.path.basename(sys.argv[0])
	print >>sys.stderr
	print >>sys.stderr, "Factorials are the product of all positive integers <= a given number."
	sys.exit(2)

args = sys.argv[1:]
if (args == []):
	usage()
else:
	try:
		num = eval(string.join(args))
		print "fact(", num, ") =", fact.fact(num)
	except:
		for arg in args:
			num = eval(arg)
			print "fact(", num, ") =", fact.fact(num)
