I have the following code:



real \x; int \i; real \s;
    \s = 0;
    for \i in {1,2,...,15}{
        \s = \s + 2^\i; 
        \x{\i} = \s;


\foreach \i in {1,2,...,15}{
O valor da soma \i~ é desta sequência é \x{\i} \\ 


Why tikzmath does not perform the calculations above of 2^14? How can I overcome this please? Any package, library to do calculation with bigger numbers?


1 Answer 1


The sagetex package gives you access to the Python programming language and a computer algebra system known as Sage. This lets you handle most any problem easily. Search this site for other examples.

output = r""
sum = 0
for i in range(1,37):
  sum += 2^i
  output += r"\noindent O valor da soma $%d$ é desta sequência é $%d$\\"%(i,sum)

The output running in Cocalc is: enter image description here

The %d is for integer data, %f is for float and %s for string data.

Sage is not part of the LaTeX distribution. It can be downloaded onto your computer but the simplest way to get started is a free Cocalc account.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .