Jump to content
» Pat

Prime Time!

Recommended Posts

Posted

Somebody should have corrected me about divisable. ):...

79

Posted

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;
}

Posted

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

Posted

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.

Posted

It's quite obvious what it does & it was a joke. ):...



×
×
  • Create New...