Commit ab518084a2e62e7aeff797b984acf4c34c5d4f8d
1 parent
6be964e1
Added interpreter and converted to UNIX format
Showing
3 changed files
with
31 additions
and
25 deletions
15.py
1 | -import sys; | ||
2 | - | ||
3 | -def factorial(num): | ||
4 | - result = 1; | ||
5 | - for x in range (num,1,-1): | ||
6 | - result *= x; | ||
7 | - return result; | ||
8 | - | ||
9 | -def binomial(m,n): | ||
10 | - return factorial(m)/(factorial(n)*factorial(m-n)); | ||
11 | - | ||
12 | -dimension = int(sys.argv[1]); | ||
13 | -print "Result is: " + str(binomial(dimension*2,dimension)); | 1 | +#!/usr/bin/python |
2 | + | ||
3 | +import sys; | ||
4 | + | ||
5 | +def factorial(num): | ||
6 | + result = 1; | ||
7 | + for x in range (num,1,-1): | ||
8 | + result *= x; | ||
9 | + return result; | ||
10 | + | ||
11 | +def binomial(m,n): | ||
12 | + return factorial(m)/(factorial(n)*factorial(m-n)); | ||
13 | + | ||
14 | +dimension = int(sys.argv[1]); | ||
15 | +print "Result is: " + str(binomial(dimension*2,dimension)); |
16.py
1 | -import math; | ||
2 | -import sys; | ||
3 | - | ||
4 | -def sumDigits(num): | ||
5 | - sum = 0; | ||
6 | - for i in range (0,len(num)): | ||
7 | - sum += int(num[i]); | ||
8 | - | ||
9 | - return sum; | ||
10 | - | ||
11 | - | ||
12 | -print "Result is: " + str(sumDigits(str(int(math.pow(int(sys.argv[1]),int(sys.argv[2])))))) | 1 | +#!/usr/bin/python |
2 | + | ||
3 | +import math; | ||
4 | +import sys; | ||
5 | + | ||
6 | +def sumDigits(num): | ||
7 | + sum = 0; | ||
8 | + for i in range (0,len(num)): | ||
9 | + sum += int(num[i]); | ||
10 | + | ||
11 | + return sum; | ||
12 | + | ||
13 | + | ||
14 | +print "Result is: " + str(sumDigits(str(int(math.pow(int(sys.argv[1]),int(sys.argv[2])))))) |