######################### # SHP Computer Programming in Python # February 2nd 2019 # Name : Kelly Ryu # # File contains algorithm for calculating the product of two arbitrary integers ######################### again = "Yes" while again == "Yes": # Ask user to input two integers to be multiplied first = int(input('Write the first integer to be multiplied: ')) second = int(input('Write the second integer to be multiplied: ')) # If second number is odd, add "first" to the list of numbers to be added if second % 2 == 1: product = first else: product = 0 # Until second number reaches 0 or 1, multiply "first" by 2 # and divide "second" by 2 # Add multiple of first number to list if result of division is 1 while second > 1: second = second // 2 first = 2 * first if second % 2 == 1: product = product + first # Print result of all necessary addition as the final product print("The product is {}.".format(product)) again = input("Would you like to find another product? (Yes/No): " )