Finally, I have found a solution that generates non-primes that can easily be understood by the layman. int nonprime() {return (rand() + 2) * 5;}
Interestingly enough this also can be used to find prime numbers, as no number returned by this function is an element of the set of primes, greatly reducing the search space.
Name:
Anonymous2013-06-27 1:04
someone give this man a fields medal
Name:
Anonymous2013-06-27 1:11
Slightly more efficient version: int nonprime() {return (rand() << 1) + 2 /*thanks adam*/;}
Name:
Anonymous2013-06-27 2:58
Most optimized version: int nonprime() {return 4;}
>>3
but then if rand() returns 0 then the answer is prime
Name:
Anonymous2013-06-27 3:55
>>1
Congratulations for publicising, perhaps unvolontarily, the stupidity of rooting everything in infinite set theory and why a constructivist approach is needed.
Name:
Anonymous2013-06-27 4:17
>>8
Congratulations for publicising, perhaps unvolontarily, the stupidity of rooting everything in constructivism and why an infinite set theory approach is needed.
Name:
Anonymous2013-06-27 6:30
adam is a Jew name
Name:
Anonymous2013-06-27 6:44
Shalom! amirite xD
Name:
Anonymous2013-06-27 6:56
>>7
Okay, how about this: int nonprime(){int x = (rand() == 0) ? (rand() << 1) + 4 : (rand() << 1) + 2; return x;}
Name:
Anonymous2013-06-27 7:42
>>12
don't try and turn this into a troll attempt, i'm onto you
...you could use some type of two-step per prime thingy =) so every composite number only requires one prime factor.. and any other primes are shifted ahead to new composites on the queue