Shading 25 squares within a square using `\foreach`
How can I resist to this golf challenge !
\documentclass[tikz,border=7pt]{standalone}
\begin{document}
\begin{tikzpicture}
\foreach~in{0,...,24}
\fill[shift={({mod(~,5)+.5},{div(~,5)})},gray,rotate=45]rectangle(45:1);
\draw rectangle(5,5);
\end{tikzpicture}
\end{document}
EDIT: A second code that is 2 characters longer but use a single loop with only 5 iterates.
\documentclass[tikz,border=7pt]{standalone}
\begin{document}
\begin{tikzpicture}
\fill[gray,even odd rule,rotate=45]
foreach~in{1,3,...,9}{(~-10,-~)rectangle(10-~,~)};
\draw(45:-10)rectangle(45:10);
\end{tikzpicture}
\end{document}
Is this what you want?
\begin{tikzpicture}
\foreach \y in {0,2,...,8}{%
\foreach \x in {0,2,...,8}{%
\draw[fill=black!50,xshift=\x cm, yshift=\y cm]%
(0:1cm) -- (90:1cm) -- (180:1cm) -- (270:1cm) -- cycle;
}%
}%
\draw (-1,-1) rectangle (9,9);
\end{tikzpicture}
Edit: the same visual result but with counters in range 0,1,2,3,4
which easily is seen to have 5 values.
\foreach \y in {0,1,...,4}{%
\foreach \x in {0,1,...,4}{%
\draw[fill=black!50,xshift=\x cm, yshift=\y cm]
(0:.5cm) -- (90:.5cm) -- (180:.5cm) -- (270:.5cm) -- cycle;
}%
}%
\draw (-.5,-.5) rectangle (4.5,4.5);
Similar to @Sigur's answer, just using your length conventions (in case you want to add something in the same conventions).
\documentclass{amsart}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\foreach \Y in {0,...,4}
{\foreach \X in {0,...,4}
{\draw[fill=gray!50] ({(1/4)*sqrt(2)/2+(1/4)*(2*sqrt(2)/2)*\X},{(1/4)*(2*sqrt(2)/2)*\Y}) --
({(1/4)*(2*sqrt(2)/2)+(1/4)*(2*sqrt(2)/2)*\X},{(1/4)*sqrt(2)/2+(1/4)*(2*sqrt(2)/2)*\Y}) --
({(1/4)*sqrt(2)/2+(1/4)*(2*sqrt(2)/2)*\X},{(1/4)*(2*sqrt(2)/2)+(1/4)*(2*sqrt(2)/2)*\Y}) --
({(1/4)*(2*sqrt(2)/2)*\X},{(1/4)*sqrt(2)/2+(1/4)*(2*sqrt(2)/2)*\Y}) -- cycle;}}
%
\draw (0,0) -- ({(1/4)*(5*sqrt(2))},0) -- ({(1/4)*(5*sqrt(2))},{(1/4)*(5*sqrt(2))}) -- (0,{(1/4)*(5*sqrt(2))}) -- cycle;
%
\end{tikzpicture}
\end{document}