In this section, we are going to see how to solve a complex math problem that asks us to solve this question: what is the sum of the digits of the number 2 to the 1,000th power?
We can solve this problem with just one line of code in Ruby.
Start by running the equation 2 to the 1,000th power and then convert the value into a string:
p (2 ** 1000).to_s
If you execute this code, the output will be as follows:
"10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652624386837205668069376"
This is the value of 2 to the power of 1,000. The next part of the code should add each digit and create a final sum.
...