2012年11月24日

#! /usr/bin/env python
# coding: utf-8

def factorial(number):
    i = 2
    result = 1
    while i <= number :
        result = result*i
        i +=1
    else:
        return result
while True :
    num = raw_input('this is where you type(number or exit):') or 'exit'

    if num == 'exit' :
        raise SystemExit
    if int(num) < 0:
        print "wrong input"
    else:
        print "\nthe result of factorial is",factorial(int(num)),"\n"

没有评论: