When evaluating a product, often the product symbol \(\prod\) appears with the same limits repeatedly. A "memory" command \memprod allows for the limits to be typed once when the product first appears and omitted thereafter. In particular, there are two versions of \memprod: a starred version \memprod*[<lower limit>][<upper limit>] records the lower limit <lower limit> and the upper limit <lower limit> into memory. From then on, the unstarred version \memprod will insert a product with the recorded limits. In addition to saving time typing, \memprod simplifies the LaTeX code, so it is easier to edit and find mistakes.

WARNING: Be careful while using this command because each time the starred version is called, it changes the definition for all of the unstarred versions until the next starred version. Thus, if you add \memprod* into the middle of text where you are already using \memprod with a different definition, you can unintentionally change the rendered equations. For this reason, I restrict the usage of each remembered command to a single equation.

Definition
% The 'xparse' package provides \NewDocumentCommand
\usepackage{xparse}
\NewDocumentCommand{\memprod}{sO{}O{}}{%
    \IfBooleanT{#1}%
    {% If a star
        % "\gdef" is used to define a global macro.
        \gdef\memprodlimits{_{#2}^{#3}}%
    }
    \prod\memprodlimits
}

Examples

Code Output
\memprod*[n=1][\infty] \frac{1}{n} 
= \memprod \frac{1}{n}
$$\begin{aligned} \prod_{n=1}^{\infty} \frac{1}{n} &= \prod_{n=1}^{\infty} \frac{1}{n} \end{aligned} $$