Coding on Recursion (Loop)

From your official website I get this Syntax of Loop:
LOOP(Vector1, Vector2, Offset1, Offset2, Operator)

and example:

SET X = LOOP(X, 1, 1, 0, ADD)
And now X contains the series 1,2,3,4,5,6,…n

What if I want the series of 1,2,3,4,5 only not to …n. Please help

You can use IF condition IF or you can define X<=5 using DEF

please give the complete code for this