Thread: Primes with Sieve of Eratosthenes.

  1. #16
    Registered User
    Join Date
    Oct 2005
    Posts
    10
    Add this library: This is a small example

    #include <math.h>

    double w, r, d;

    d = (sqrt(w)) / r;

  2. #17
    Registered User
    Join Date
    Nov 2005
    Posts
    9
    Code:
    while (n < MAX) {
           divisible = FALSE;
           for (i = 0; (i < sqrt(n)) && !divisible; i++)
               divisible = ((candidat % p[i]) == 0);
    Is it that ?

  3. #18
    Registered User
    Join Date
    Nov 2005
    Posts
    9
    Quote Originally Posted by SARAHCPS
    Add this library: This is a small example

    #include <math.h>

    double w, r, d;

    d = (sqrt(w)) / r;

    I think like that its more slow!

  4. #19
    Super Moderator Harbinger's Avatar
    Join Date
    Nov 2004
    Posts
    74
    Well try not calling sqrt() so many times - like just ONCE before the loop, not every time within the loop.

  5. #20
    Registered User
    Join Date
    Nov 2005
    Posts
    9
    Quote Originally Posted by Harbinger
    Well try not calling sqrt() so many times - like just ONCE before the loop, not every time within the loop.
    How, cannot understand you writte som code pls.

  6. #21
    Super Moderator Harbinger's Avatar
    Join Date
    Nov 2004
    Posts
    74
    Bored now.....


    int limit = sqrt ( fooo );
    for (i = 0; i < limit ; i++ )

    If you can't get that into your code, give it up

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Finding primes
    By scwizzo in forum C++ Programming
    Replies: 11
    Last Post: 09-10-2008, 06:15 PM
  2. Prime Sieve Optimization
    By rt454 in forum C++ Programming
    Replies: 9
    Last Post: 05-30-2008, 09:22 PM
  3. primes program need some help
    By Mshock in forum C Programming
    Replies: 2
    Last Post: 04-17-2006, 07:21 PM
  4. primes
    By godfather in forum C++ Programming
    Replies: 3
    Last Post: 05-08-2002, 01:44 PM
  5. sieve of Erotosthenes (HELP!!!)
    By JFK in forum C Programming
    Replies: 1
    Last Post: 02-19-2002, 12:53 PM