haskell memory allocation


#1

I want to allocate more memory because my teacher challenged me to show him the first 12 and last 12 digits of the expression 2 ^ 17179869184


#2

You shouldn’t really need need more memory allocation for this task!
If I have a very-big-number® like

a = (1000 digits here).....................12

What will the last two digits of a*2 be?


#3

For the first 12 digits you can do something similar by using exponentiation by squaring.

If we know only the first n digits of a, then how many digits of a ^ 2 can we know?

Maybe the reverse is more useful in this case: if we want to know the first n digits of a then how many digits of sqrt a do we need to know?

Surprisingly, read (take n (show a)) is the fastest way (I could find) to get the first n digits of a.