Skip to content

Instantly share code, notes, and snippets.

@ChristopherBilg
Created March 14, 2018 16:28
Show Gist options
  • Save ChristopherBilg/7a6af589e7fe20ea92c4f0be423016ca to your computer and use it in GitHub Desktop.
Save ChristopherBilg/7a6af589e7fe20ea92c4f0be423016ca to your computer and use it in GitHub Desktop.
r/DailyProgrammer Integer Complexity 1
#!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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment