recursive fuction

J

joel_maina

using the following recursive defination how do i write a fuction to
compute this.
X0=1
Xn= (Xn/2)2, if n>0 and n is even.
Xn=X*(Xn/2)2, if n>0and n is odd
 
J

jacob navia

(e-mail address removed) a écrit :
using the following recursive defination how do i write a fuction to
compute this.
X0=1
Xn= (Xn/2)2, if n>0 and n is even.
Xn=X*(Xn/2)2, if n>0and n is odd

Do your own homework joel, do not try to cheat.

Or, if you like, give us the address of your teacher and we will send
directly to him the answers...
 
B

Ben Bacarisse

using the following recursive defination how do i write a fuction to
compute this.
X0=1
Xn= (Xn/2)2, if n>0 and n is even.
Xn=X*(Xn/2)2, if n>0and n is odd

These don't make much sense. Check that you have got them right.
Also this is a newsgroup that discusses the C language so, at the very
least, post a stab at doing it in C first. If you are asking in more
general terms, comp.programming would be a better place.
 
R

Richard Heathfield

Ben Bacarisse said:
These don't make much sense.

Yes they do, if you've done Intermediate Mind-Reading (Level 2 or
above).

He's just trying to write a function (call it intpow) to raise an
integer to an integer power. So intpow(X, 0) is 1, intpow(X, even) is
intpow(X, even/2) squared, and intpow(X, odd) is X * intpow(X, odd/2)
squared.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top