\documentclass{article}
\usepackage{graphicx,multido}

\newcommand{\KREUZ}{\makebox[4mm]{\scalebox{1.75}{$\times$}}}
\newcommand{\BOX}{\makebox[4mm]{\phantom{\scalebox{1.75}{$\times$}}}}
\newcommand{\testTeiler}[2]{\directlua{
    if math.fmod(#1,#2) == 0
      then tex.print("\string\\KREUZ")
      else tex.print("\string\\BOX")
    end }}
\show\testTeiler
\newcommand{\Aufgabe}[1]{%
  #1 \multido{\iA=0+1}{12}{%
    \tabular[t]{@{}c@{}}\frame{%
      \ifnum\iA>0 \testTeiler{#1}{\iA}\else \BOX\fi}\\
    \iA\endtabular}}

\begin{document}

\makebox[6cm][r]{\Aufgabe{12}} \par
\makebox[6cm][r]{\Aufgabe{1982267}} \par
\makebox[6cm][r]{\Aufgabe{1983267}}

\end{document}


%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% TeX-engine: luatex
%%% End: 
