PL/SQL PROGRAM
FIBONACCI SERIES
AIM:
To write a program to create
functions for finding the Fibonacci series
ALGORITHM:
Step 1: Start the program
Step 2: declare the variables
Step 3 : initialize a=-1,b=-1 and i=1
Step 4 : get the value of a
Step 5: if n is less than or equal
to 0 ,then print 1 type correct
Value of n
Step 6: while I is less than or
equal to n then
a) calculate
c as the sum of a & b
b) print
the value of c
c) store
the value b to a
d) store
the value of c to b
e) increment
the value of I by 1
Step 7 : Stop the program
PROGRAM:
SQL> set serveroutput on
SQL> declare A number(5):=0;
2
b number(5):=1;
3
c number(5);
4
i number(5):=2;
5
n number(5);
6
begin
7
n:=&n;
8
dbms_output.put_line(A);
9
dbms_output.put_line(b);
10
while(i<n)
11
loop
12
c:=A+b;
13
dbms_output.put_line(c);
14
A:=b;
15
b:=c;
16
i:=i+1;
17
end loop;
18
end;
19
/
OUTPUT:
Enter value for n: 5
old 7: n:=&n;
new 7: n:=5;
0
1
1
2
3
PL/SQL procedure successfully
completed.
1 comments:
takes for u help its very useful
Post a Comment