T-Systems interview question

Questions on strings Pattern printing