Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!usr/bin/env python3
- """
- This script is the r/DailyProgrammer Easy Challenge #354 titled
- Integer Complexity 1.
- Author: Christopher Bilger
- """
- import math as Math
- class Integer():
- """
- This class handles the calculations involving the input integer.
- """
- def __init__(self, integer):
- self.integer = integer
- self.multiples = []
- for factor in range(1, Math.floor(integer/2)):
- if integer % factor == 0:
- self.multiples.append(factor+(integer/factor))
- def get_smallest_multiple(self):
- """
- Getter method for the smallest integer in the Integer.multiples list
- @return int Smallest integer in the list
- """
- if len(self.multiples) == 0:
- return 0
- elif len(self.multiples) == 1:
- return int(self.multiples[0])
- smallest = self.multiples[0]
- for index in range(1, len(self.multiples)):
- if self.multiples[index] < smallest:
- smallest = self.multiples[index]
- return int(smallest)
- def main():
- """
- The main method that will be executed and will print out
- the smallest integers.
- """
- print("4567 | " + str(Integer(4567).get_smallest_multiple()))
- print("12345 | " + str(Integer(12345).get_smallest_multiple()))
- print("345678 | " + str(Integer(345678).get_smallest_multiple()))
- if __name__ == '__main__':
- main()
Add Comment
Please, Sign In to add comment