A community for students.
Here's the question you clicked on:
 0 viewing
anonymous
 one year ago
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,b1)
anonymous
 one year ago
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,b1)

This Question is Open
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.