Search:

Type: Posts; User: Salem

Search: Search took 0.32 seconds.

  1. Thread: isPrime

    by Salem
    Replies
    25
    Views
    5,025

    But it is in the initial assignment part...

    But it is in the initial assignment part (evaluated once), and not the condition or step parts (which are evaluated every time).
  2. Thread: isPrime

    by Salem
    Replies
    25
    Views
    5,025

    > for (i = 3, r = sqrt(number) ; i

    > for (i = 3, r = sqrt(number) ; i <= r && prime ; i += 2)
    Watch this
    https://en.wikipedia.org/wiki/File:Sieve_of_Eratosthenes_animation.gif

    What you should have for i+=2 is something...
Results 1 to 2 of 2