Why 2 ** 3 ** 2 ** 1 is 512? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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?

20th Sep 2019, 1:18 PM
edward 🇷🇴
edward 🇷🇴 - avatar
17 Answers
+ 20
2**3**2**1 = 2**3**(2**1) = 2**(3**2) = 2**9 = 512
20th Sep 2019, 1:25 PM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar
+ 5
edward da, sunt. 😁
20th Sep 2019, 2:00 PM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar
+ 5
it runs right to left many people showd that: 2**3**2**1 = 2**3**(2**1) = 2**(3**2) = 2**9 = 512
20th Sep 2019, 4:44 PM
Mohamed El-Sayed
Mohamed El-Sayed - avatar
+ 3
~ swim ~ I need to give that associativity another look, keep forgetting how they work 😁 Big Thanks for clarification 👍
20th Sep 2019, 1:54 PM
Ipang
+ 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.
22nd Sep 2019, 7:58 AM
GAYATHRI KOLLURI
GAYATHRI KOLLURI - avatar
+ 2
🍇Alex Tusinean 💜 so it's backward, thanks (off topic, I'm guessing you are romanian, right?)
20th Sep 2019, 1:33 PM
edward 🇷🇴
edward 🇷🇴 - avatar
+ 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?
20th Sep 2019, 1:35 PM
Ipang
+ 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
20th Sep 2019, 8:15 PM
edward 🇷🇴
edward 🇷🇴 - avatar
+ 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.
21st Sep 2019, 10:48 AM
Siham
+ 2
Go right to left
22nd Sep 2019, 5:09 AM
Huzaifa Khilawala
Huzaifa Khilawala - avatar
+ 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
22nd Sep 2019, 9:50 AM
Siham
+ 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
21st Sep 2019, 6:33 AM
Shweta B
Shweta B - avatar
+ 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.
22nd Sep 2019, 8:59 AM
Siham
+ 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.
22nd Sep 2019, 9:01 AM
Siham
+ 1
2**9=512
22nd Sep 2019, 9:06 AM
Anwar Ali
Anwar Ali - avatar
0
Please give me clarity
20th Sep 2019, 2:53 PM
sandeep reddy
sandeep reddy - avatar
0
It's not from right to left it's just "to the power" ***1 **2 *3 2
23rd Sep 2019, 1:27 PM
Tomislav Mamić
Tomislav Mamić - avatar