My solutions to the problems found at Project Euler.

Jump to: | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 17 | 20 | 21 | 22 | 25 | 3-2 |

Problem 5

```#! /usr/bin/ptyhon
# Problem: Find the smallest number divisable evenly by every number between
#          1 and 20.
#
# Attack Plan: Multiply all factors together which cannot be made up of our other
#              factors.
#
# This solution, although led me to the right answer by deduction, it is not
# a progmatic solution and does not complete the problem.
#
# See 5-2.py for my next attempt.

import copy

# Borrowed from 3.py!
def find_whole_factors(n):
" Create a list of all whole-number factors for any given n"
factors = []
possible_factor = n
while possible_factor > 0:
if n % possible_factor == 0:
factors.append(possible_factor)
possible_factor -= 1

return factors

if __name__ == "__main__":

min_range = 1
max_range = 20

factors = range(min_range, max_range+1, 1)

factors_reversed = copy.copy(factors)
factors_reversed.reverse()

removal_list = []
do_not_remove = []

# Eliminate all factors which can be made up of TWO of our other factors, starting
# with the highest values.
for n in factors_reversed: # For every factor.
print n
for x in factors: # Multiply every factor,
for y in factors: # By every other factor.

if not x == 1 and not x == n and \
not y == 1 and not y == n and \
not x == y:

if x*y == n: # Our factor can be made up of two other factors
if n == 20: print '!',x,y
if not n in removal_list:
removal_list.append(n)
if not x in do_not_remove:
if x == 10: print '!',n
do_not_remove.append(x)
if not y in do_not_remove:
if y == 10: print '!',n
do_not_remove.append(y)

for number in removal_list:
if number in factors and  \
not number in do_not_remove:
factors.remove(number)

# Multiply remaining factors by themselves.
product = 1
for number in factors:
product *= number

print factors, ' ', product

```