diff --git a/e_6.py b/e_6.py index 3eb13a6..0003b7b 100755 --- a/e_6.py +++ b/e_6.py @@ -9,12 +9,26 @@ natural numbers and the square of the sum. #--- """ -def sum_squares(): +def diff_sum_squares(value): """ Returns the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum. """ - return 1 + return squares_sum(value) - sum_squares(value) + +def sum_squares(value): + """ + Returns the sum of the square of elements from 1 to value + """ + vals = range(1, value + 1) + return sum([pow(val, 2) for val in vals]) + +def squares_sum(value): + """ + Returns the square of the sum of elements from 1 to value + """ + return pow(sum(range(1, value + 1)), 2) if __name__ == '__main__': - print "Answer : %d " % (sum_squares()) + val = 100 + print "Answer : %d " % (diff_sum_squares(val)) diff --git a/e_7.py b/e_7.py new file mode 100755 index 0000000..4374c60 --- /dev/null +++ b/e_7.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python +""" +#--- + Julien Lengrand-Lambert + Created on : Wed Jan 11 14:42:54 CET 2012 + + DESCRIPTION : Solves problem 7 of Project Euler + By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see + that the 6th prime is 13. + What is the 10 001st prime number? +#--- +""" +def prime_list(value): + """ + Returns the vlst prime number + """ + + return 1 + + + + + +if __name__ == '__main__': + val = 10001 + print "Answer : %d " % (prime_list(val)) +