Help with functions and loops

Can you provide a reproducible example?