How to solve this problem | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

How to solve this problem

print( 2 ** 3 ** 2) = 512 🤷‍♂️ how

7th Oct 2020, 7:29 AM
I, am
I, am - avatar
5 Answers
+ 5
2^9 right ?
7th Oct 2020, 7:32 AM
Rei
Rei - avatar
+ 10
2*2*2*2*2*2*2*2*2=512 2 * 1 = 2 2 * 2 = 4 2 * 4 = 8 2 * 8 = 16 2 * 16 = 32 2 * 32 = 64 2 * 64 = 128 2 * 128 =256 2 * 256 =512
8th Oct 2020, 5:11 PM
ᵘᵐᵉᵈ
ᵘᵐᵉᵈ - avatar
+ 6
I, am , to get the correct understanding of this expression, you should keep in mind, that exponentiation starts at the very right side of the expression (this is due to the operator precedence rules ): 2 ** 3 ** 2 THIS IS THE CORRECT WAY: ---------------------------- 1. step: 3**2 is calculated -> 9 2. step: 2**9 is calculated -> 512
7th Oct 2020, 11:06 AM
Lothar
Lothar - avatar
+ 4
Lothar thanks
7th Oct 2020, 11:32 AM
I, am
I, am - avatar