I am trying to create a worksheet constituted of random numbers so that kids can practice integer operations. E.g.
3+-9=?
2x(-5)=?
18/-3=?
Etc.
How do I do this?
Here is what I've tried so far.
\documentclass{minimal}
\usepackage{tikz}
\begin{document}
\pgfmathparse{random(-10,10)}
\pgfmathresult
\end{document}
Two problems.
- Why is there an extra 0.0. before the integer?
- Why is that random number 7 when my bounds are -10 and 10? Picking 7 repeatedly seems pretty non-random.
Some of this was mentioned in another thread but that thread is now a couple of years old.
Got ideas?
Thanks!
Best Answer
To work around the bug of the
random
function, you may defined a newrandomfixed
function:Now, you may generate a random integer between two boundaries with parentheses for negative integer:
You may generate random operators:
To change the seed of the pseudo-random generator each second, you may use the
\pdfuniformdeviate
macro:All the code:
And a result: