473,320 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

hello , Do anybody know the answer of this questuion

The classic algorithm for calculating the prime numbers in the range 2..n is due to Eratosthenes:
initialize the set of primes, P, to be all integers in 2..n;
for ( i = 2; 2*i <= n; i = i+1 )
{ remove from P all multiples of i };
print the contents of P;

Implement this algorithm by modelling P as an array of booleans: boolean[] P = new boolean[n + 1]. (Hint: P[i] == false means that i is definitely not a prime.)

So , if anybody know how to write this code ... so please do it :). Thanks a lot
May 18 '07 #1
1 1102
bartonc
6,596 Expert 4TB
The classic algorithm for calculating the prime numbers in the range 2..n is due to Eratosthenes:
initialize the set of primes, P, to be all integers in 2..n;
for ( i = 2; 2*i <= n; i = i+1 )
{ remove from P all multiples of i };
print the contents of P;

Implement this algorithm by modelling P as an array of booleans: boolean[] P = new boolean[n + 1]. (Hint: P[i] == false means that i is definitely not a prime.)

So , if anybody know how to write this code ... so please do it :). Thanks a lot
Sounds a lot like homework. Please take some time to read the Posting Guidelines in order to undstand some of the Site Rules.

Thanks for joining.

<moving to misc. discuss.>
May 21 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: CyberLotus | last post by:
Hi, I'm new to OOPS and I need to call an application from BizTalk orchestration. And I can understand that I need to write a COM for that. Can anybody let me know how to write a COM in .NET? ...
2
by: bissatch | last post by:
Hi, I am trying to use JavaScript to write a table column on a web page. The code is as follows: <html> <head> <script> function displaycount() {
9
by: andrew | last post by:
Hi, I posted this message recently, but received no response, so I figured I'd try again. I can't find anybody who can tell me what's going on here. I'm having a problem with fieldsets in IE...
6
by: Edward | last post by:
hi, everyone, I've found many examples of OWC chart, but all are VB version, when I tried to transform it into C#, compiler told me, "cannot find ChartSpace in OWC", while the same class can...
1
by: Alireza Kheyrollahi | last post by:
This is the third time I am posting this message. Please help if you can. ------------------------------------------- Hi all, I have got three questions. For the first two, I need just...
8
by: Xero | last post by:
Hello. Could anybody suggest a way to create a timer? I want to timer to be displayed to the user, telling he or she how much time has passed. Thanks. -- Xero
0
by: senthilraj | last post by:
i have a problem, i have two combo boxes. both are selected and display the result. while displaying the second combo box value is changed and it display the first value corresponding to the first...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.