Identification Division.
Program-Id. Check-Fibonacci.
Environment Division.
Data Division.
Working-Storage Section.
77 N Pic 9999.
77 Prev Pic 9999 Value 0.
77 Curr Pic 9999 Value 1.
77 Nextn Pic 99999 Value 0.
77 Switch Pic 9 Value 0.
Screen Section.
01 Main-Screen.
02 Line 4 Column 10 " The Program to Check if a Number is a Fi
- "bonacci " Reverse-Video Blink.
02 Line 6 Column 10 "The Fibonacci Series is 0 , 1 , 1 , 2 ,
- " 3 , 5 , 8....." Highlight.
02 Line 8.
02 Column 10 "Enter a Number : " Highlight.
02 Column 30 Pic 9999 To N.
01 Fibo-Scr.
02 Line 10 Column 10 "It is a Fibonacci Number" Highlight.
01 Not-Fibo-Scr.
02 Line 10 Column 10 "It is Not a Fibonacci Number"
Highlight.
Procedure Division.
Initialize-Read-Para.
Display Main-Screen.
Accept Main-Screen.
Perform Fibonacci-Para Until (Prev > N ).
If (Switch = 1)
Display Fibo-Scr
Else
Display Not-Fibo-Scr.
Stop Run.
Fibonacci-Para.
If (Prev = N )
Move 1 to Switch.
Compute Nextn = Prev + Curr.
Move Curr To Prev.
Move Nextn To Curr.