+ 5
Why 2 ** 3 ** 2 ** 1 is 512?
Can someone explain to me why 2 ** 3 ** 2 ** 1 is 512? My logic(which seems to not work) says that 2**3=8**2=64**1=64. So what am I missing here?
19 Réponses
+ 20
2**3**2**1 = 2**3**(2**1)
= 2**(3**2)
= 2**9
= 512
+ 5
edward da, sunt. 😁
+ 5
it runs right to left many people showd that:
2**3**2**1 = 2**3**(2**1)
= 2**(3**2)
= 2**9
= 512
+ 3
~ swim ~
I need to give that associativity another look, keep forgetting how they work 😁
Big Thanks for clarification 👍
+ 3
For ** operator the associativity is from right to left
i.e first 2**1=2 and then 3**2=9 and at last 2**9=512.
+ 2
🍇Alex Tusinean 💜 so it's backward, thanks (off topic, I'm guessing you are romanian, right?)
+ 2
🍇Alex Tusinean 💜
I thought it goes left to right when all the operators are the same (only ** used there), but in this case it goes right to left, why is that? operator associativity?
+ 2
sandeep reddy "in an unparenthesized sequence of power ad unary operators, the
operators are evaluated from right to left (this does not constrain the evaluation order for the operands)." From python docs: https://docs.python.org/2.0/ref/power.html
+ 2
Take it as 2power (3*2*1) multiply on the top all number exist in the power to make it one resulted then apply the simple usual operation . Always remember to avoid compkexity in math simplify and make it easy as any child see it. Math is all about l8gic and simple optic.
+ 2
Go right to left
+ 2
Just work out power which is 3**(2**1) = 3**2 because 2**1=2 》》》》3**2=3*3=9
After simplyfing the top apply as usual on the main ooeration 2**9=2*2*2*2*2*2*2*2*2=512
Sorry one inswer I did muktiply instead of using poer onbthe top so ut is 2**9 and not 2**6
+ 1
Since The operators are grouped from right to left and ** means power I.e. n**m=n to the power m. So
2**(3**(2**1))
=2**(3**2)
=2**9
=512
+ 1
Just work out exponentiation than finish the initial or main operation . All power puktiply them to find one inky result (digit) then apply it on the value or varuable . Just keep simplifying . The principal here is not to start from rightvto keftbor oposit . ! But to work out the power to have one digit and then finish youlast task by appky the power in the variabke.
+ 1
This is the pure logic behind the way you work it to land on 512 so simpify than perform your main operation after simpkifying it.
+ 1
2**9=512
0
Please give me clarity
0
It's not from right to left it's just "to the power"
***1
**2
*3
2