\documentclass[border=2mm, varwidth]{standalone}
\usepackage{tikz}
\begin{document}
Test:
\def\N{24}
\def\C{\N}
\pgfmathsetmacro\Cp{\C-1}
\foreach[count=\No] \n in {\N,...,3}{
\pgfmathsetmacro\newC{mod(\C,2)==0 ? \C/2 : 3*\C+1}
\xdef\C{\newC}
% Try
% \ifnum\newC>1 \C \fi % He does not do that!!! :(
% Output:
\n, \No:~ \C \\
}
\end{document}