A Very Simple Recursionn

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Dec 2005
Posts: 10
Reputation: thehakan is an unknown quantity at this point 
Solved Threads: 0
thehakan thehakan is offline Offline
Newbie Poster

A Very Simple Recursionn

 
0
  #1
Dec 24th, 2005
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?
Reply With Quote Quick reply to this message  
Join Date: Nov 2005
Posts: 78
Reputation: perniciosus is an unknown quantity at this point 
Solved Threads: 4
perniciosus's Avatar
perniciosus perniciosus is offline Offline
Junior Poster in Training

Re: A Very Simple Recursionn

 
0
  #2
Dec 24th, 2005
m(x) = x < 3 ? 0 : m(x - 1) + m(x - 3) + 1
/pern.*/i

Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. Albert Einstein
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 10
Reputation: thehakan is an unknown quantity at this point 
Solved Threads: 0
thehakan thehakan is offline Offline
Newbie Poster

Re: A Very Simple Recursionn

 
0
  #3
Dec 24th, 2005
thank u
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum


Views: 1297 | Replies: 2
Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC