Table of Contents
Introduction
The task is to find the minimum sum of factors of the given number.
Program
def find(ip_no): # Initilize sum with 0 output_sum = 0 fact = 2 while(fact * fact <= ip_no): while(ip_no % fact == 0): output_sum += fact ip_no /= fact fact += 1 output_sum += ip_no print("The minimum sum of factors of given number is {0}".format(output_sum) ) ip_no = int(input("Enter the number: ")) find(ip_no)
Output
Explanation
Approach:
- Find the factors of the given number.
- Add the factors and store the value in the sum variable.
- Repeat the steps for all the factors of the given number.
- Return the minimum sum.
0 Comments