What am I doing wrong in the following Matlab recursion programming project?

85 Views Asked by At

Write a recursive function (using Matlab) moreFactors(a,b,fact) that does the following:

  1. Takes as an input 3 positive integers.

  2. Of the two integers a and b, the function returns the integer that has the most factors fact.

  3. If both integers a and b have the same amount of factors fact, the function will return the larger integer.

Test your function with the following:

result=moreFactors(24,32,3)

result = 24

(24 = 3^1 · 2^3 , 32 = 2^5 )

result=moreFactors(32,24,3)

result = 24

result=moreFactors(80,168,2)

result = 80

(80 = 2^4 · 5, 168 = 2^3 · 3 · 7)

result=moreFactors(100,50,5)

result = 100

(100 = 2^2 · 5^2 , 50 = 2 · 5^2 )

Note: function must be recursive!

Wrapper Function

Inside Function