Prime number in PL/SQL Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 declare part, we declare variables and between begin and end part, we perform the operations.Examples: Input : 5 Output : true Input : 10 Output : false Below is the required implementation: SQL declare -- declare variable n, i -- and temp of datatype number n number; i number; temp number; begin -- Here we Assigning 13 into n n := 13; -- Assigning 2 to i i := 2; -- Assigning 1 to temp temp := 1; -- loop from i = 2 to n/2 for i in 2..n/2 loop if mod(n, i) = 0 then temp := 0; exit; end if; end loop; if temp = 1 then dbms_output.put_line('true'); else dbms_output.put_line('false'); end if; end; -- Program End Output: true Comment More infoAdvertise with us Next Article Reverse a number in PL/SQL V vt_m Follow Improve Article Tags : Misc DSA Prime Number SQL-PL/SQL Practice Tags : MiscPrime Number Similar Reads Reverse a number in PL/SQL Prerequisite - PL/SQL introduction In PL/SQL code groups of commands are arranged within a block. A block group related declarations or statements. In declare part, we declare variables and between begin and end part, we perform the operations. Explanation: Consider the example, input = 12345. Step 2 min read Swap two numbers in PL/SQL In PL/SQL code groups of commands are arranged within a block. A block group related declarations or statements. In declare part, we declare variables and between begin and end part, we perform the operations. Basic structure of pl/sql block declare -- declare all the variables begin -- for start bl 1 min read Program for Fibonacci numbers in PL/SQL 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- 1 min read Prime Number Chart Prime Number Chart is a helpful tool used to display and identify prime numbers. Prime Numbers are natural numbers greater than 1 that can only be divided by 1 and the number itself. Unlike composite numbers, which can be divided by other numbers, primes are unique because of their indivisibility. F 4 min read GCD of two numbers in PL/SQL Prerequisite - PL/SQL introduction In PL/SQL code groups of commands are arranged within a block. A block group related declarations or statements. In declare part, we declare variables and between begin and end part, we perform the operations. Given two numbers and task is to find the GCD (Greatest 1 min read Sum Of Two Numbers in PL/SQL Prerequisite - PL/SQL introductionIn PL/SQL code groups of commands are arranged within a block. A block group related declarations or statements. In declare part, we declare variables and between begin and end part, we perform the operations. Here, first, we take three variables x, y, and z and ass 2 min read Like