From ab518084a2e62e7aeff797b984acf4c34c5d4f8d Mon Sep 17 00:00:00 2001 From: Imanol-Mikel Barba Sabariego Date: Wed, 23 Dec 2015 14:30:13 +0100 Subject: [PATCH] Added interpreter and converted to UNIX format --- 15.py | 28 +++++++++++++++------------- 16.py | 26 ++++++++++++++------------ 17.py | 2 ++ 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/15.py b/15.py index 399955c..0b424af 100755 --- a/15.py +++ b/15.py @@ -1,13 +1,15 @@ -import sys; - -def factorial(num): - result = 1; - for x in range (num,1,-1): - result *= x; - return result; - -def binomial(m,n): - return factorial(m)/(factorial(n)*factorial(m-n)); - -dimension = int(sys.argv[1]); -print "Result is: " + str(binomial(dimension*2,dimension)); +#!/usr/bin/python + +import sys; + +def factorial(num): + result = 1; + for x in range (num,1,-1): + result *= x; + return result; + +def binomial(m,n): + return factorial(m)/(factorial(n)*factorial(m-n)); + +dimension = int(sys.argv[1]); +print "Result is: " + str(binomial(dimension*2,dimension)); diff --git a/16.py b/16.py index 2dbbe74..efb196e 100755 --- a/16.py +++ b/16.py @@ -1,12 +1,14 @@ -import math; -import sys; - -def sumDigits(num): - sum = 0; - for i in range (0,len(num)): - sum += int(num[i]); - - return sum; - - -print "Result is: " + str(sumDigits(str(int(math.pow(int(sys.argv[1]),int(sys.argv[2])))))) +#!/usr/bin/python + +import math; +import sys; + +def sumDigits(num): + sum = 0; + for i in range (0,len(num)): + sum += int(num[i]); + + return sum; + + +print "Result is: " + str(sumDigits(str(int(math.pow(int(sys.argv[1]),int(sys.argv[2])))))) diff --git a/17.py b/17.py index c23dd48..f5a301d 100755 --- a/17.py +++ b/17.py @@ -1,3 +1,5 @@ +#!/usr/bin/python + import sys; def getLetterNum(num): -- libgit2 0.22.2