# What is the value of $2^{3000}$ [closed]

What is the value of $2^{3000}$?

How to calculate it using a programming language like C#?

-

## closed as off topic by Start wearing purple, Andrew, Pedro Tamaroff♦, Tom Oldfield, Parth KohliJun 9 '13 at 8:51

Questions on Mathematics Stack Exchange are expected to relate to math within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

The value is best put as $2^{3000}$. In binary, it's a 1 followed by 3000 zeros. The number is roughly 900 decimal digits long, so unless you have good reason to express it in decimal, you're probably better off with binary. – Glen O Apr 26 '13 at 13:44
In most programming languages, you need some sort of big number package. Then there will be an operation for it, which will result in a proper representation of the number. In some, like Python, Mathematica, PARI/GP it is built in – Ross Millikan Apr 26 '13 at 13:53
@Hermann It is certainly not too big to be represented in a computer (e.g. I can compute it on my phone using the Android version of Maxima). Probably what you meant to write is that the integer is too big to be represented in a single machine word of existing computers. – Math Gems Apr 26 '13 at 13:59
Why does this question keep getting down votes? The FAQ makes it clear that questions concerning mathematical software is on topic. While fairly elementary, this question is not just about mathematical software, but about the mathematics of mathematical software. – Mark McClure Apr 26 '13 at 14:09
I honestly think this question is off topic here and it belongs to comuputer stuff. – DonAntonio Apr 27 '13 at 0:30

In C# (.Net 4.0 or higher) you can obtain the desired value like this:

String result = BigInteger.Pow(2, 3000).ToString();

-

1230231922161117176931558813276752514640713895736833715766118029160058800614672948775360067838593459582429649254051804908512884180898236823585082482065348331234959350355845017413023320111360666922624728239756880416434478315693675013413090757208690376793296658810662941824493488451726505303712916005346747908623702673480919353936813105736620402352744776903840477883651100322409301983488363802930540482487909763484098253940728685132044408863734754271212592471778643949486688511721051561970432780747454823776808464180697103083861812184348565522740195796682622205511845512080552010310050255801589349645928001133745474220715013683413907542779063759833876101354235184245096670042160720629411581502371248008430447184842098610320580417992206662247328722122088513643683907670360209162653670641130936997002170500675501374723998766005827579300723253474890612250135171889174899079911291512399773872178519018229989376

Found using Wolfram Alpha

-
(-!) What do u want to show by copy pasting from wolfram? – ABC Apr 26 '13 at 13:44
I believe this answers one of the two questions that were asked; not everyone is aware of this tool. – vadim123 Apr 26 '13 at 13:44
@exploringnet I think this is a pretty adequate answer to such question. He asked for value and he got it. If it seems useless to you - blame the question not the answer. – Juris Apr 26 '13 at 13:50
It is somewhat depressing that this is my #2 answer of all time. – vadim123 Apr 26 '13 at 14:05
Update: it is particularly depressing that this is now my #1 answer of all time. I can only assume that this is why all the upvotes. – vadim123 Apr 30 '13 at 4:19

In order to avoid numerical overflow problems, some kind of arbitrary precision arithmetic is required to store numbers this large. Many computer algebra systems include arbitrary precision arithmetic.

One may also use a bignum library such as GMP. Here's a C implementation:

#include <stdio.h>
#include <gmp.h>

int main() {
mpz_t two,two_to_the_three_thousand;

mpz_init_set_ui(two,2);
mpz_init(two_to_the_three_thousand);

mpz_pow_ui(two_to_the_three_thousand,two,3000);

gmp_printf("%Zd\n",two_to_the_three_thousand);

mpz_clear(two);
mpz_clear(two_to_the_three_thousand);

return 0;
}

which we compile with gcc by:

gcc temp.c -lgmp

which outputs

1230231922161117176931558813276752514640713895736833715766118029160058800614672948775360067838593459582429649254051804908512884180898236823585082482065348331234959350355845017413023320111360666922624728239756880416434478315693675013413090757208690376793296658810662941824493488451726505303712916005346747908623702673480919353936813105736620402352744776903840477883651100322409301983488363802930540482487909763484098253940728685132044408863734754271212592471778643949486688511721051561970432780747454823776808464180697103083861812184348565522740195796682622205511845512080552010310050255801589349645928001133745474220715013683413907542779063759833876101354235184245096670042160720629411581502371248008430447184842098610320580417992206662247328722122088513643683907670360209162653670641130936997002170500675501374723998766005827579300723253474890612250135171889174899079911291512399773872178519018229989376
-

Here is what I got using PARI/GP by typing 2^3000

• PARI is a C library, allowing fast computations.

• gp is an easy-to-use interactive shell giving access to the PARI functions. GP is the name of gp's scripting language.

-

A MATLAB solution seems fit for I believe there are lots of MATLAB/Octave users here.

There is a Variable Precision Integer Arithmetic package in MATLAB file exchange that creates a class named vpi, and all relevant methods like power, log, etc. The usage is like MATLAB built-in uint32 or unit64. Add path to whichever folder that has this package. Type

>> A = vpi(2)^3000

>> A = 123023192216111717693155881327675251464071389573683371576611802916005 880061467294877536006783859345958242964925405180490851288418089823682358 508248206534833123495935035584501741302332011136066692262472823975688041 643447831569367501341309075720869037679329665881066294182449348845172650 530371291600534674790862370267348091935393681310573662040235274477690384 047788365110032240930198348836380293054048248790976348409825394072868513 204440886373475427121259247177864394948668851172105156197043278074745482 377680846418069710308386181218434856552274019579668262220551184551208055 201031005025580158934964592800113374547422071501368341390754277906375983 387610135423518424509667004216072062941158150237124800843044718484209861 032058041799220666224732872212208851364368390767036020916265367064113093 699700217050067550137472399876600582757930072325347489061225013517188917 4899079911291512399773872178519018229989376

And the data type of A can be retrieved by

>> class(A)

ans =vpi

Pretty useful for people working on encryption.

-

On a pocket calculator (using natural logs to restrict to the functions available in most computer languages), I computed $$3000\times\frac{\log(2)}{\log(10)}=903.089986991943$$ I then computed $$\exp(0.089986991943\times\log(10))=1.23023192215946$$ Thus, getting $$2^{3000}=1.23023192216\times10^{903}$$ I trimmed off three digits from the mantissa since I lost three digits of significance in the log to $903$.

Not exact, but it might do in a pinch.

For a more exact answer, the following Java expression should do the trick

BigInteger("2").pow(3000).toString()

-