diff --git a/004.py b/004.py index d754d22..3ee4745 100644 --- a/004.py +++ b/004.py @@ -7,5 +7,5 @@ def palindrome(): palindromes[i * ii] = [i, ii] p = sorted(palindromes.keys(), reverse=True)[0] print 'Palindrome: {0}x{1}: {2}'.format(palindromes[p][0], palindromes[p][1], p) - -palindrome() +if __name__ == '__main__': + palindrome() diff --git a/005.py b/005.py index f4674a4..4f7318d 100644 --- a/005.py +++ b/005.py @@ -8,5 +8,5 @@ def divisible(n): break if ii == 1: return x - -print 'Smallest number: ', divisible(20) +if __name__ == '__main__': + print 'Smallest number: ', divisible(20) diff --git a/006.py b/006.py index 91c8006..1470d52 100644 --- a/006.py +++ b/006.py @@ -1,9 +1,11 @@ def squarediff(n): + print 'Checking for n =', n sumofsquares = sum([x**2 for x in range(n + 1)]) print 'Sum of squares', sumofsquares squareofsum = sum(range(n + 1))**2 print 'Square of sum', squareofsum print 'Difference', squareofsum - sumofsquares -squarediff(10) -squarediff(100) +if __name__ == '__main__': + squarediff(10) + squarediff(100) diff --git a/007.py b/007.py index 3129d24..0af7cd4 100644 --- a/007.py +++ b/007.py @@ -12,5 +12,6 @@ def primes(limit): i = i + 2 return primes -print '6th Prime', primes(6)[-1] -print '10001st Prime', primes(10001)[-1] +if __name__ == '__main__': + print '6th Prime', primes(6)[-1] + print '10001st Prime', primes(10001)[-1]