\documentclass[a4paper,11pt]{book}
\usepackage[polish]{babel}
\usepackage[utf8]{inputenc} 
\usepackage[T1]{fontenc}
\usepackage{fourier}
\usepackage{algpseudocodex}
\usepackage[chapter]{algorithm}
\usepackage{xcolor}
\usepackage{geometry}

\geometry{width=126mm}

\algrenewcommand\algorithmicrequire{\bfseries Wejście:}
\algrenewcommand\algorithmicensure{\bfseries Wyjście:}

\begin{document}

\chapter{Składanie algorytmów w pseudokodzie}
\label{cha:algorytmy}

\begin{algorithmic}[1]
\Require $a, b \in \mathbb{N}$
\Ensure NWD $a,b$\Comment{Największy Wspólny Dzielnik a i b}
\While{$a \ne b$}
  \BeginBox[fill=gray!30]
    \If{$a>b$}
      \State $a\gets a-b$
    \Else
      \State $b\gets b-a$
    \EndIf
  \EndBox
\EndWhile
\State\Return $a$
\end{algorithmic}

\end{document}