Python Tutorial

Wednesday, December 5, 2012

Problem solving using python: Small factorials


Small factorials: https://www.spoj.pl/problems/FCTRL2/

All source code available on github

# python 2.7
def fact(n):
    if n==0:
        return 1
    return n*fact(n-1)

n = input()
while n>0:
    n=n-1
    k=input()
    print fact(k)

0 comments:

Post a Comment