Home » SQL & PL/SQL » SQL & PL/SQL » To Calculate Prime Numbers in a range between 1 and 100 and insert it into a table
icon6.gif  To Calculate Prime Numbers in a range between 1 and 100 and insert it into a table [message #223346] Thu, 08 March 2007 09:35 Go to next message
ramesha.smiley
Messages: 19
Registered: 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.

THANX WELL IN ADVANCE,
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 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: 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 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: 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 Go to previous message
ddkdhar
Messages: 68
Registered: February 2007
Member

check this link


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: Fri Dec 09 06:01:16 CST 2016

Total time taken to generate the page: 0.08981 seconds