Answer to Question #248737 in Databases | SQL | Oracle | MS Access for Tarurendra Kushwah

Question #248737
Write a program in PL/SQL to print the prime numbers between 1 to 100.
1
Expert's answer
2021-10-08T23:50:38-0400
DECLARE
    n NUMBER(3);
    m NUMBER(3);
BEGIN
dbms_output.Put_line('The prime numbers between 1 and 100 are:');
	dbms_output.new_line;
    n := 2;
    LOOP
        m := 2;
        LOOP
            EXIT WHEN( ( MOD(n, m) = 0 )
                        OR ( m = n ) );
            m := m + 1;
        END LOOP;
        IF( m = n )THEN
          dbms_output.Put(n||'   ');							   
        END IF;
        n := n + 1;
        exit WHEN n = 100;
    END LOOP;
	dbms_output.new_line;
END;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS