I'm making an built with random numbers, that is effectively guessing and checking to solve systems such as:
mn=-10
m+n=3
where m and n are random integers.
Strangely, I notice no cases where m+n=0, except when m=n=0. I've recompiled quite a few times and still haven't found a single case.
Why? Is the random number generation not as random as I thought?
Here is the code, which generates both the exercises (first and third columns) as well as the and the solutions (second and fourth columns).
\documentclass{article}
\usepackage[margin=1.5cm, landscape]{geometry}
\usepackage{ifthen}
\usepackage{multicol}
\setlength{\columnsep}{1.5cm}
\usepackage{pgf}
\usepackage{pgffor}
\setlength{\parindent}{0pt}
\pgfmathsetseed{\number\pdfrandomseed}
\newcommand{\InitVariables}
{
\pgfmathsetmacro{\m}{int(random(0,5)-5)}
\pgfmathsetmacro{\n}{int(random(0,5)-5)}
\pgfmathsetmacro{\sum}{int(\m+\n)}
\pgfmathsetmacro{\product}{int(\m*\n)}
\pgfmathtruncatemacro{\Structure}{random(1,4)}
}
\newcommand{\onequestion}
{
\large
\InitVariables
\_\_\_\_\_\_\_\_ \(\times\) \_ \_ \_ \_ \(=\product\) \hspace{4cm} \(\m\times\n=\product\)
\vspace{0.8cm}
\_\_\_\_\_\_\_\_ \(+\) \_ \_ \_ \_ \ \(=\sum\) \hspace{4cm} \(\m+\n=\sum\)
\vspace{1.6cm}
}
\pagestyle{empty}
\newcommand{\onepage}
{
\begin{center} \Huge Integer Pairs\end{center}
\vspace{0.5cm}
\begin{multicols}{2}
\onequestion
\onequestion
\onequestion
\onequestion
\onequestion
\onequestion
\onequestion
\onequestion
\onequestion
\onequestion
\end{multicols}
\pagebreak
}
\begin{document}
\onepage
\onepage
\end{document}
m+n=3then you should never getm+n=0! :) – Nov 11 '16 at 06:52