i would consider the following table layout:

\documentclass{article}
\usepackage{amsmath}
\usepackage{booktabs, makecell}
\newcommand\mcc[1]{\multicolumn{2}{>{$}c<{$}}{#1}}
\begin{document}
\begin{table}
\centering
\begin{tabular}{>{$}r<{$}*{6}{>{$}c<{$}}}
\toprule
& \multicolumn{6}{c}{$\max i$} \\
\cmidrule{2-7}
& \mcc{i\equiv0\pmod4} & \mcc{i \equiv1\pmod 4} & \mcc{i\equiv0\pmod 4} \\
\cmidrule(r){2-3}\cmidrule(lr){4-5}\cmidrule(l){6-7}
\multicolumn{1}{c}{$n$}
& m\text{ even}
& m\text{ odd} & m\text{ even}
& m\text{ odd} & m\text{ even}
& m\text{ odd} \\
\midrule
4n & 2m & 2m-2 & - & - & - & - \\
4n +1 & - & - & - & - & - & - \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
edit: pmod
is stolen from Bernard answer :-)
addendum:
adding one column pairs to above table widens it. this can cause the table to be wider than the text and will consequently protrude right text margin (your page layout is not known, since you not provide complete small document -- mwe -- with your table code snippet; now you can see how important this is).
assuming, that text width in your document as is default provided by article
. in this case is necessary to change spaces between columns. in this is sensible to left this to latex
with the replacing
\centering
\begin{tabular}{>{$}r<{$}*{6}{>{$}c<{$}}}
to
\setlength\tabcolsep{0pt}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
>{$}r<{$}
*{8}{>{$}c<{$}}}
where @{\extracolsep{\fill}}
accommodate \tabcolsep
(spaces between columns) to value, which enable to fit table in text width (if the width of the text is large enough). complete mwe is:
\documentclass{article}
\usepackage{amsmath}
\usepackage{booktabs, makecell}
\newcommand\mcc[1]{\multicolumn{2}{>{$}c<{$}}{#1}}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\begin{document}
\begin{table}
\setlength\tabcolsep{0pt}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
>{$}r<{$}
*{8}{>{$}c<{$}}}
\toprule
& \multicolumn{8}{c}{$\max i$} \\
\cmidrule{2-9}
& \mcc{i\equiv0\pmod4} & \mcc{i \equiv1\pmod 4} & \mcc{i\equiv0\pmod 4} & \mcc{i\equiv2\pmod 4} \\
\cmidrule(r){2-3}\cmidrule(lr){4-5}\cmidrule(lr){6-7}\cmidrule(l){8-9}
\multicolumn{1}{c}{$n$}
& m\text{ even}
& m\text{ odd} & m\text{ even}
& m\text{ odd} & m\text{ even}
& m\text{ odd}
& m\text{ even}
& m\text{ odd} \\
\midrule
4n & 2m & 2m-2 & - & - & - & - & - & - \\
4n +1 & - & - & - & - & - & - & - & - \\
\bottomrule
\end{tabular*}
\end{table}
\end{document}

(red lines indicate page layout)
note:
in table design you first select type of table. beside of basic tabular
are other possibilities: tabular*
(which has prescribed width, see mwe anove), tabularx
, etc. with its options, determine the number and type of columns. for example:
\begin{tabular}{cccc}
is basic table with four columns. it also can be write as
\begin{tabular}{*{4}{c}}
in your case
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
>{$}r<{$}
*{8}{>{$}c<{$}}}
has nine columns and table width is \linewidth
(which is value of temporary width of environment where the table is placed. in your case it is equal to \textwidth
.
[!h]
latex will warn and change it to[!ht]
but removingp
makes it a lot more likely that the figure goes to the end, and!
should only be needed vary rarely, so[htp]
is usually a better choice. – David Carlisle Jun 5 '18 at 15:32