2012年11月25日

#! /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):')
    while not num.isdigit():
        if num == 'exit' :
            raise SystemExit
        num = raw_input('Wrong input, try again:')
    else:
        print "\nthe result of factorial is",factorial(int(num)),"\n"

没有评论: