#!/usr/bin/env python # Problem 5: # # 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? # import decorators # Typically imported to compute execution duration of functions. import time # Typically imported for sleep function, to slow down execution in terminal. import typing def evenly_divisible(candidate: int,factors: list): """ Determines if the supplied integer candidate is evenly divisble by the supplied list of factors. evenly_divisible(candidate: int, factors: list) param 'candidate': Integer to be tested. param 'factors': List of factors for the modulus operator. """ modulus_sum = 0 for n in factors: modulus_sum += candidate%n if modulus_sum == 0: return True else: return False @decorators.function_timer def main(): # Receive problem inputs... smallest_factor = 1 largest_factor = 17 # Compute intermediate inputs factor_list = [int(i) for i in range(smallest_factor,largest_factor+1)] maximum_solution_bound = 1 for f in factor_list: maximum_solution_bound *= f # Initialize loop parameters n = 10 test_passed = False while n