Ask Question
5 June, 05:48

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

+4
Answers (1)
  1. 5 June, 06:30
    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?
Get 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 & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers