0

how does ** works (python)

i've created program, which runs a while, than stops and doesn't return anything, i've tried running only part where is power: n = 2 ** (2 ** 5 - 1) - 1 a = 2 ** (n - 1) #line, where program stops working, out of memory print(a) does anybody knows how to solve this?

23rd Nov 2019, 9:12 AM
nicolas turek
nicolas turek - avatar
4 Respuestas
+ 3
(2**31 - 1) is a pretty large value. Then in next line you have- (2**(2**31-1)-1) is still bigger. So you cannot accomodate that is all I'm saying.
23rd Nov 2019, 9:21 AM
Avinesh
Avinesh - avatar
+ 2
2**5 means 2*2*2*2*2, it is exponentiation.
23rd Nov 2019, 9:14 AM
Avinesh
Avinesh - avatar
- 1
well, i know what does ** do... it's power function, the question maybe should be, how to make power for laaarge numbers, which overflows memory
23rd Nov 2019, 9:17 AM
nicolas turek
nicolas turek - avatar
- 1
ok, thanks
23rd Nov 2019, 9:24 AM
nicolas turek
nicolas turek - avatar