Home » SQL & PL/SQL » SQL & PL/SQL » To Calculate Prime Numbers in a range between 1 and 100 and insert it into a table
To Calculate Prime Numbers in a range between 1 and 100 and insert it into a table Thu, 08 March 2007 09:35
 ramesha.smiley Messages: 19Registered: August 2006 Location: Chennai Junior Member
hi mates,
im a new member in this forum.
I wanna ask you for a logic or program to calculate the prime numbers in a range between 1 and 100 and then insert it into a table.

CALCULATE PRIME NUMBERS FROM 1 TO 100.

Re: To Calculate Prime Numbers in a range between 1 and 100 and insert it into a table [message #223347 is a reply to message #223346] Thu, 08 March 2007 09:39
 Frank Messages: 7880Registered: March 2000 Senior Member
Ok, this looks like a homework assignment, so let's treat it like that.
Step 1: How would you (regardless of SQL) do this calculation?
Re: To Calculate Prime Numbers in a range between 1 and 100 and insert it into a table [message #223348 is a reply to message #223347] Thu, 08 March 2007 09:41
 Maaher Messages: 7062Registered: December 2001 Senior Member
I think I saw a thread regarding prime numbers in the past...

Why don't you search for it?

MHE
Re: To Calculate Prime Numbers in a range between 1 and 100 and insert it into a table [message #223360 is a reply to message #223346] Thu, 08 March 2007 11:50
 ddkdhar Messages: 68Registered: February 2007 Member

with t
2 as
3 (select level+1 id from dual connect by level < :bound )
4 select id from t x1
5 where not exists
6 (
7 select 1 from t x2 where
8 mod(x1.id , x2.id) = 0
9 and x2.id>1
10 and x2.id<ceil(x1.id/2)+1
11 ) and x1.id<10000 and x1.id>0
12 /
 Previous Topic: Trim extra space (merged) Next Topic: Drop Column
Goto Forum:

Current Time: Thu Aug 17 01:09:50 CDT 2017

Total time taken to generate the page: 0.05146 seconds