Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Fibonacci Series program in ABAP

Former Member
0 Likes
2,115

Hi experts,

Plz send me the code for Fibonacci Series.

Hi experts,

Plz send me the code for Fibonacci Series.

1 REPLY 1
Read only

Former Member
0 Likes
1,137

Hi,

Take a look :

DATA: output TYPE i.
PARAMETERS: p_num TYPE i.
START-OF-SELECTION.
PERFORM fibo USING p_num
CHANGING output.
WRITE:/ output.
*&---------------------------------------------------------------------*
*& Form fibo
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM fibo USING num
CHANGING out.
DATA: lv_num1 TYPE i,
lv_num2 TYPE i,
out1 TYPE i,
out2 TYPE i.
IF num > 2.
lv_num1 = num - 1.
PERFORM fibonacci USING lv_num1
CHANGING out1.
lv_num2 = num - 2.
PERFORM fibonacci USING lv_num2
CHANGING out2.
out = out1 + out2.
ELSE.
out = num.
ENDIF.
ENDFORM. 

Hope this helps,

Erwan