int p(int x)
{ if(x<3)
return x;
else
return p(x-1) * p(x-3);
}

say m(x) is a number of multiplication operations that the execution of p(x) performs.
what can be recursive definition of m(x)??

Answer should be (x-1)*(x-3) . Am I wrong?

m(x) = x < 3 ? 0 : m(x - 1) + m(x - 3) + 1

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.