There are various ways to accomplish your needs.
\documentclass[11pt]{article}
\usepackage{xparse} % for D
% for A, B, C
\newcounter{mycount}
\makeatletter
\newcommand\repeatstringA[2]{%
\setcounter{mycount}{#1}%
\ifnum\themycount>0
#2%
\addtocounter{mycount}{-1}%
\expandafter\@firstofone
\else
\expandafter\@gobble
\fi
{\repeatstringA{\themycount}{#2}}%
}
\newcommand\repeatstringB[2]{%
\setcounter{mycount}{#1}%
\@whilenum{\value{mycount}>0}\do{#2\addtocounter{mycount}{-1}}%
}
\newcommand\repeatstringC[2]{%
\ifnum#1>0
\expandafter\@firstofone
\else
\expandafter\@gobble
\fi
{#2\expandafter\repeatstringC\expandafter{\the\numexpr#1-1\relax}{#2}}%
}
\makeatother
\ExplSyntaxOn
\DeclareExpandableDocumentCommand{\repeatstringD}{mm}
{
\prg_replicate:nn { #1 } { #2 }
}
\ExplSyntaxOff
\begin{document}
\repeatstringA{5}{abc}
\repeatstringB{5}{abc}
\repeatstringC{5}{abc}
\repeatstringD{3*2-1}{abc}
\end{document}
The last one is particularly appealing. The first two are essentially equivalent.

If you want to produce a control sequence containing the repetitions, then the changes are easy:
\documentclass[11pt]{article}
\usepackage{xparse} % for D
% for A, B, C
\newcounter{mycount}
% a container
\newcommand{\concathere}{}
\makeatletter
\newcommand\repeatstringA[2]{%
\renewcommand{\concathere}{}%
\setcounter{mycount}{#1}%
\ifnum\themycount>0
\expandafter\def\expandafter\concathere\expandafter{\concathere #2}%
\addtocounter{mycount}{-1}%
\expandafter\@firstofone
\else
\expandafter\@gobble
\fi
{\repeatstringA{\themycount}{#2}}%
}
\newcommand\repeatstringB[2]{%
\setcounter{mycount}{#1}%
\@whilenum{\value{mycount}>0}\do{%
\expandafter\def\expandafter\concathere\expandafter{\concathere #2}%
\addtocounter{mycount}{-1}%
}%
}
\newcommand\repeatstringC[2]{%
\ifnum#1>0
\expandafter\@firstofone
\else
\expandafter\@gobble
\fi
{%
\expandafter\def\expandafter\concathere\expandafter{\concathere #2}%
\expandafter\repeatstringC\expandafter{\the\numexpr#1-1\relax}{#2}%
}%
}
\makeatother
\ExplSyntaxOn
\NewDocumentCommand{\repeatstringD}{mm}
{
%\tl_clear:N \concathere
%\prg_replicate:nn { #1 } { \tl_put_right:Nn \concathere { #2 } }
% a faster method suggested by Bruno Le Floch
\tl_set:Nx \concathere { \prg_replicate:nn { #1 } { \exp_not:n { #2 } } }
}
\ExplSyntaxOff
\begin{document}
\repeatstringA{5}{abc}\concathere
\repeatstringB{5}{abc}\concathere
\repeatstringC{5}{abc}\concathere
\repeatstringD{3*2-1}{abc}\concathere
\end{document}
At the end of the execution of \repeatstringX{5}{abc}
the macro \concathere
will contain abcabcabcabcabc
.
Instead of
\expandafter\def\expandafter\concathere\expandafter{\concathere #2}
(where \def
is used for efficiency), you can of course use
\appto\concathere{#2}
provided you have loaded etoolbox
.
None of these methods will overflow the input stack size; however, big numbers may overflow other parts of the memory.