\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,calc}
\usepackage{xcolor}
\usepackage{xfp}
\usepackage{pgf,pgffor}

\begin{document}

\newcommand\recurr[3]{%#1=fct,#2=u0,#3=nfinal
	\foreach \i [remember=\i as \x (initially #2)] in {1,...,#3}{%
		\def\y{\fpeval{#1}}
		\draw[color=magenta](\x,\x)--(\x,\y)--(\y,\y);
		\draw[color=orange,dotted,line width=0.8pt] (\x,\x)--(\x,0) node[below=6pt]{$u_\i$};
		\def\i{\fpeval{\y}}%
	}
}
	
	\begin{tikzpicture}
		\def\f(#1){sqrt(5*\x)+1}
		\draw[thick,->] (0,0)--(10,0) ;
		\draw[thick,->] (0,0)--(0,8) ;
		\draw[color=blue,samples=250,domain=0:8] plot (\x,{\f(\x)}) ;
		\draw[color=green] (0,0)--(8,8) ;
		\recurr{\f(\x)}{1}{5}
	\end{tikzpicture}
	
\end{document}