DATA: output TYPE i.
PARAMETERS: p_num TYPE i.
START-OF-SELECTION.
PERFORM factorial USING p_num
CHANGING output.
WRITE:/ output.
*&---------------------------------------------------------------------*
*& Form factorial
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM factorial USING num
CHANGING out.
DATA: lv_num1 TYPE i,
out1 TYPE i.
IF num > 1.
lv_num1 = num - 1.
PERFORM factorial USING lv_num1
CHANGING out1.
out = num * out1.
ELSE.
out = num.
ENDIF.
ENDFORM. " factorial
Post new comment