Solves problem 4

Creates templates for code
Initiates problem 5
This commit is contained in:
Julien Lengrand-Lambert
2012-01-12 14:14:07 +01:00
parent 89f1f686df
commit 1a59914cf4
3 changed files with 58 additions and 2 deletions

18
e.py Executable file
View File

@@ -0,0 +1,18 @@
#!/usr/bin/env python
"""
#---
Julien Lengrand-Lambert
Created on : Wed Jan 11 14:42:54 CET 2012
DESCRIPTION : Solves problem of Project Euler
#---
"""
def largest():
"""
Returns
"""
return 1
if __name__ == '__main__':
print "Answer : %d " % (largest())

20
e_4.py
View File

@@ -10,10 +10,26 @@
Find the largest palindrome made from the product of two 3-digit numbers.
#---
"""
def prod_palindrom(value):
def largest_palindrom():
"""
Returns the largest palindrom made from the product of two 3-digits number
"""
return 1
three_digits = range(100, 1000)
largest = 0
for digit_1 in three_digits:
for digit_2 in three_digits:
val = digit_1 * digit_2
if is_palindrom(val):
if largest < val:
largest = val
return largest
def is_palindrom(number):
"""
returns True if a number is a palindrom, False otherwise
"""
return str(number)[::-1] == str(number)
if __name__ == '__main__':
print "Answer : %d " % (largest_palindrom())

22
e_5.py Executable file
View File

@@ -0,0 +1,22 @@
#!/usr/bin/env python
"""
#---
Julien Lengrand-Lambert
Created on : Wed Jan 11 14:42:54 CET 2012
DESCRIPTION : Solves problem 5 of Project Euler
2520 is the smallest number that can be divided by each of the numbers from 1
to 10 without any remainder.
What is the smallest positive number that is evenly divisible by all of the
numbers from 1 to 20?
#---
"""
def divisible_by_all():
"""
Returns the smallest number divisible by 1 to 20
"""
return 1
if __name__ == '__main__':
print "Answer : %d " % (divisible_by_all())