» Pat Posted November 2, 2008 Author Report Posted November 2, 2008 Somebody should have corrected me about divisable. ):... 79
Zeitgeist Posted November 6, 2008 Report Posted November 6, 2008 That would be 97; 93 ain't a prime number. Actually, I'll just post a C code of the sieve of Atkin and be on my way to /threadwin #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <math.h> int main(void) { unsigned int limit, i, j; printf("Find primes upto: "); scanf("%d", &limit); limit += 1; bool *primes = calloc(limit, sizeof(bool)); unsigned int sqrtlimit = sqrt(limit); for (i = 2; i <= sqrtlimit; i++) if (!primes[i]) for (j = i * i; j < limit; j += i) primes[j] = true; printf("\nListing prime numbers between 2 and %d:\n\n", limit - 1); for (i = 2; i < limit; i++) if (!primes[i]) printf("%d\n", i); return 0; }
Zeitgeist Posted November 6, 2008 Report Posted November 6, 2008 Ah, and don't try to calculate primes up to a large limit. I don't guarantee your computer's survival if you do.
» Pat Posted November 6, 2008 Author Report Posted November 6, 2008 Have you ever played a game? ): Oh& here is something for you. ): It's not C, though. qq Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Do Beep() Loop End Sub
Zeitgeist Posted November 6, 2008 Report Posted November 6, 2008 Not like anyone is going to go ahead and compile that anyways. Don't know what source your code is, but I can understand what it does and, yeah. No thanks.
» Pat Posted November 6, 2008 Author Report Posted November 6, 2008 It's quite obvious what it does & it was a joke. ):...
do_ob Posted November 6, 2008 Report Posted November 6, 2008 3! FAIL THE NEXT PRIME NUMBER AFTER 1 IS 2 Thread was lose from the start thanks to sieg :(
Zeitgeist Posted November 6, 2008 Report Posted November 6, 2008 Which is why I posted a code for a prime number calculator.