how can i catch prime numbers with While Loop ? [message #319432] |
Sun, 11 May 2008 02:52 |
|
Hany Freedom
Messages: 256 Registered: May 2007 Location: Egypt
|
Senior Member |
|
|
I want to make Pl/SQL program using WHILE LOOP , which will accept integer from 1 to 50 and generate the prime numbers as shown in the following output :-
The prime numbers from 1 to 50 are as follows :
1,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47
How suppose that's done ?!
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: how can i catch prime numbers with While Loop ? [message #319692 is a reply to message #319460] |
Mon, 12 May 2008 12:20 |
|
Barbara Boehmer
Messages: 9100 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
It should only take a few lines of code to do this.
SCOTT@orcl_11g> SET SERVEROUTPUT ON
SCOTT@orcl_11g> DECLARE
2 ...;
3 ...;
4 BEGIN
5 WHILE ... LOOP
6 ...;
7 WHILE ... LOOP
8 IF ... THEN ...;
9 ELSIF ... THEN ...;
10 END IF;
11 IF ... THEN ...;
12 END IF;
13 ...;
14 END LOOP;
15 ...;
16 END LOOP;
17 ...;
18 END;
19 /
1,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47
PL/SQL procedure successfully completed.
SCOTT@orcl_11g>
|
|
|