4 replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
source | link

Is there such a thing as a prime real number?

If not then the function signature should use integer (preferably unsigned as there are no negative primes).

Then you should be able to use % rather than fmod() which I would suspect is a tad faster but, more importantly, easier to read.

Since you have already checked for all even primes:

for (int i = 3; i < sqrt(value); i+=2) {
                            //   ^^^^  No need to increment by 1;
                            //         All evens already checked already so inc by 2
                            //         So just check 3/5/7/9 etc

Here is a link to cool but not obvious optimization (That allows you to avoid checking all multiples of 3 as well as 2): http://codereview.stackexchange.com/a/7342/507https://codereview.stackexchange.com/a/7342/507

Is there such a thing as a prime real number?

If not then the function signature should use integer (preferably unsigned as there are no negative primes).

Then you should be able to use % rather than fmod() which I would suspect is a tad faster but, more importantly, easier to read.

Since you have already checked for all even primes:

for (int i = 3; i < sqrt(value); i+=2) {
                            //   ^^^^  No need to increment by 1;
                            //         All evens already checked already so inc by 2
                            //         So just check 3/5/7/9 etc

Here is a link to cool but not obvious optimization (That allows you to avoid checking all multiples of 3 as well as 2): http://codereview.stackexchange.com/a/7342/507

Is there such a thing as a prime real number?

If not then the function signature should use integer (preferably unsigned as there are no negative primes).

Then you should be able to use % rather than fmod() which I would suspect is a tad faster but, more importantly, easier to read.

Since you have already checked for all even primes:

for (int i = 3; i < sqrt(value); i+=2) {
                            //   ^^^^  No need to increment by 1;
                            //         All evens already checked already so inc by 2
                            //         So just check 3/5/7/9 etc

Here is a link to cool but not obvious optimization (That allows you to avoid checking all multiples of 3 as well as 2): https://codereview.stackexchange.com/a/7342/507

3 improved formatting, fixed typos
source | link

Is theirthere such a thing as a prime real number?

If not then the function signature should use integer (preferably unsigned as there are no negative primes).

Then you should be able to use %% rather than fmod()fmod() which I would suspect idis a tad faster nutbut, more importantly, easier to read.

Since you have already checked for all even primes:

for (int i = 3; i < sqrt(value); i+=2) {
                            //   ^^^^  No need to increment by 1;
                            //         All evens already checked already so inc by 2
                            //         So just check 3/5/7/9 etc

Here is a link to cool but not obvious optimization (That allows you to avoid checking all multiples of 33 as well as 22):
   http://codereview.stackexchange.com/a/7342/507

Is their such a thing as a prime real number?

If not then the function signature should use integer (preferably unsigned as there are no negative primes).

Then you should be able to use % rather than fmod() which I would suspect id a tad faster nut more importantly easier to read.

Since you have already checked for all even primes:

for (int i = 3; i < sqrt(value); i+=2) {
                            //   ^^^^  No need to increment by 1;
                            //         All evens already checked already so inc by 2
                            //         So just check 3/5/7/9 etc

Here is a link to cool but not obvious optimization (That allows you to avoid checking all multiples of 3 as well as 2):
 http://codereview.stackexchange.com/a/7342/507

Is there such a thing as a prime real number?

If not then the function signature should use integer (preferably unsigned as there are no negative primes).

Then you should be able to use % rather than fmod() which I would suspect is a tad faster but, more importantly, easier to read.

Since you have already checked for all even primes:

for (int i = 3; i < sqrt(value); i+=2) {
                            //   ^^^^  No need to increment by 1;
                            //         All evens already checked already so inc by 2
                            //         So just check 3/5/7/9 etc

Here is a link to cool but not obvious optimization (That allows you to avoid checking all multiples of 3 as well as 2):  http://codereview.stackexchange.com/a/7342/507

2 added 337 characters in body
source | link

Is their such a thing as a prime real number?

If not then the function signature should use integer (preferably unsigned as there are no negative primes).

Then you should be able to use % rather than fmod() which I would suspect id a tad faster nut more importantly easier to read.

Since you have already checked for all even primes:

for (int i = 3; i < sqrt(value); i+=2) {
                            //   ^^^^  No need to increment by 1;
                            //         All evens already checked already so inc by 2
                            //         So just check 3/5/7/9 etc

Here is a link to cool but not obvious optimization (That allows you to avoid checking all multiples of 3 as well as 2):
http://codereview.stackexchange.com/a/7342/507

Is their such a thing as a prime real number?

If not then the function signature should use integer (preferably unsigned as there are no negative primes).

Then you should be able to use % rather than fmod() which I would suspect id a tad faster nut more importantly easier to read.

Here is a link to cool but not obvious optimization:
http://codereview.stackexchange.com/a/7342/507

Is their such a thing as a prime real number?

If not then the function signature should use integer (preferably unsigned as there are no negative primes).

Then you should be able to use % rather than fmod() which I would suspect id a tad faster nut more importantly easier to read.

Since you have already checked for all even primes:

for (int i = 3; i < sqrt(value); i+=2) {
                            //   ^^^^  No need to increment by 1;
                            //         All evens already checked already so inc by 2
                            //         So just check 3/5/7/9 etc

Here is a link to cool but not obvious optimization (That allows you to avoid checking all multiples of 3 as well as 2):
http://codereview.stackexchange.com/a/7342/507

1
source | link