Program to find the minimum sum of factors of given number using Python

by | Aug 9, 2021 | Python Programs

Introduction

The task is to find the minimum sum of factors of the given number.

Program to find the minimum sum of factors of given number using Python

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

Program to find the minimum sum of factors of given number using Python 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.

Author

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.