Program for Fibonacci numbers in PL/SQL Last Updated : 13 Mar, 2023 Comments Improve Suggest changes Like Article Like Report The Fibonacci numbers are the numbers in the following integer sequence. 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, …….. In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence relation Fn = Fn-1 + Fn-1 with seed values F0= 0 and F1 = 1. Given a number n, print n-th Fibonacci Number. Input : n = 2 Output : 1 Input : n = 9 Output : 34 Below is the required implementation: SQL declare -- declare variable first = 0, -- second = 1 and temp of datatype number first number := 0; second number := 1; temp number; n number := 5; i number; begin dbms_output.put_line('Series:'); --print first two term first and second dbms_output.put_line(first); dbms_output.put_line(second); -- loop i = 2 to n for i in 2..n loop temp:=first+second; first := second; second := temp; --print terms of fibonacci series dbms_output.put_line(temp); end loop; end; --Program End Output: 0 1 1 2 3 5 Comment More infoAdvertise with us Next Article Program for Fibonacci numbers in PL/SQL V vt_m Follow Improve Article Tags : Misc DSA Prime Number Practice Tags : MiscPrime Number Similar Reads Program to find Prime Fibonacci Numbers till N Given a number, find the numbers (smaller than or equal to n) which are both Fibonacci and prime.Examples: Input : n = 40 Output: 2 3 5 13 Explanation : Here, range(upper limit) = 40 Fibonacci series upto n is, 1, 1, 2, 3, 5, 8, 13, 21, 34. Prime numbers in above series = 2, 3, 5, 13. Input : n = 10 8 min read Program to find last digit of n'th Fibonacci Number Given a number 'n', write a function that prints the last digit of n'th ('n' can also be a large number) Fibonacci number. Examples : Input : n = 0 Output : 0 Input: n = 2 Output : 1 Input : n = 7 Output : 3 Recommended PracticeThe Nth FibonnaciTry It! Method 1 : (Naive Method) Simple approach is to 13 min read Non Fibonacci Numbers Given a positive integer n, the task is to print the nth non-Fibonacci number. The Fibonacci numbers are defined as: Fib(0) = 0Fib(1) = 1for n >1, Fib(n) = Fib(n-1) + Fib(n-2)First few Fibonacci numbers are 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 141, â¦â¦.. Examples: Input : n = 2Output : 6Inpu 15 min read Sum of Fibonacci Numbers Given a number positive number n, find value of f0 + f1 + f2 + .... + fn where fi indicates i'th Fibonacci number. Remember that f0 = 0, f1 = 1, f2 = 1, f3 = 2, f4 = 3, f5 = 5, ... Examples : Input : n = 3Output : 4Explanation : 0 + 1 + 1 + 2 = 4Input : n = 4Output : 7Explanation : 0 + 1 + 1 + 2 + 3 9 min read Prime number in PL/SQL Prerequisite â PL/SQL introductionA prime number is a whole number greater than 1, which is only divisible by 1 and itself. First few prime numbers are : 2 3 5 7 11 13 17 19 23 â¦..In PL/SQL code groups of commands are arranged within a block. A block group-related declarations or statements. In decl 1 min read Like