Ask Question
12 September, 20:01

Write the function largeFactor (num) which takes in an integer num that is greater than 1. The function returns the largest integer that is smaller than num and evenly divides num. Example: largeFactor (15) will return 5 since the factors of 15 are 1, 3 and 5 largeFactor (7) will return 1 since 7 is prime

+5
Answers (1)
  1. 12 September, 23:42
    0
    The solution code is written in Python:

    def largeFactor (num) : if (num > 1) : for i in range (num-1, 0, - 1) : if (num % i = = 0) : return i else: return "Invalid value"

    Explanation:

    First, create a function, largeFactor (), that take one parameter, num (Line 1).

    Since the input number must be bigger than 1, we create a if condition to ensure the num is bigger than 1 (Line 2).

    To return the largest divisible integer, we can create a for loop that iterate through the number from num - 1 till 0 (Line 3). This will enable us to identify the largest integer which is less than num but is a factor of num and return it as output (Line 4-5).
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write the function largeFactor (num) which takes in an integer num that is greater than 1. The function returns the largest integer that is ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers