K
K
Kornev_VA2021-10-17 16:42:14
Mathematics
Kornev_VA, 2021-10-17 16:42:14

How to calculate the number 2 to the power of 1,000,000,000,000,000?

Hello, for scientific activity, you need to calculate the number 2 to the power of 1,000,000,000,000,000 (2 to the quadrillion power). How can this be calculated?
Is it better to count in Python or in other programs?
What libraries?
What code to use?...
I tried it in Python, but you can't count this number directly.

Tell me please.

Answer the question

In order to leave comments, you need to log in

7 answer(s)
G
galaxy, 2021-10-17
@galaxy

Do you exactly or approximately? If, as usual in physics, then:
2 1 000 000 000 000 000 = 10 lg(2)*1 000 000 000 000 000 = 10 301029995663981.1952137... = 10 0.1952137... * 10 301029995 = 1.69 567522 * 10 301029995663981

B
BorLaze, 2021-10-17
@BorLaze

Of course, you don't count directly.
Even if you programmatically implement arithmetic for super-large numbers, then it will be very difficult to find so much space to write a number.
Approximately, you might think. Like, we reached a million, we have the value of the 123rd degree = 1234567, we discard thousands, and remember - the 124th degree is equal to 2467 thousand.
Further - in the same way we consider 567th degree equal to 9876 million, well, and other-other-other.
Of course, it will turn out plus or minus bast shoes, but some approximate value will come out.

A
Aetae, 2021-10-17
@Aetae

There is literally nothing to calculate. 2 in N is a one and N zeros in binary. Using this information, optimize your calculations related to this "number".

W
Wataru, 2021-10-17
@wataru

2^10 ~ 10^3. 2^1,000,000,000,000,000 ~ 10^300,000,000,000,000
This is a number with many digits. Its record in the file will take 272 terabytes. Accordingly, to calculate it, you will need either a similar amount of memory, or some very tricky algorithms with writing to intermediate files and several times more disk space.
It is unlikely that your goal is to get these 300 billion digits. You probably need to do something with this number. Perhaps this can be done without calculating all the digits of the number. For example, if you need the last 100 digits, then you can use the same python to perform calculations modulo 10 ^ 100. True, you have to write exponential exponentiation yourself.

S
SagePtr, 2021-10-18
@SagePtr

Start with the correct wording of the problem. It is unlikely that you need this number, most likely, you are trying to solve some other problem, but you have chosen the wrong method for solving it.

I
iBird Rose, 2021-10-17
@iiiBird

I tried it in Python, but you can't count such a number directly.

You won't find it directly anywhere.
google about long arithmetic https://ru.wikipedia.org/wiki/%D0%94%D0%BB%D0%B8%D... and various algorithms.
for example, exponentiation can be converted to multiplication and multiplied by a ready-made algorithm. and how you will do it - I have no idea. you will need a lot of free space to write all these numbers and intermediate calculations.

N
Nikolay Savelyev, 2021-10-18
@AgentSmith

So it is considered elementary. 2^10 = 1024, 2^20 = 1048576 etc. The meaning is clear
. Translate into the binary system and go.
Calculated in less than a second

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question