Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 16 Online
OpenStudy (anonymous):

in lec8: isn't exp3(a,b) linear? Shouldn't it say (b%2)*b != b instead of (b%2)*2 == b (b%2 can only be 0 or 1 so I don't see when this is true other than for b = 0?) to make it log? Or am i missing something (that is not entirely unlikely since I've been studying too many hours today)? here is the copy pasted code (can't get the indenting to work here but it isn't that important I guess): def exp3(a,b): if b == 1: return a if (b%2)*2 == b: return exp3(a*a, b/2) else: return a*exp3(a,b-1)

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!