[ create a new paste ] login | about

Link: http://codepad.org/KVJFGWeW    [ raw code | output | fork ]

C, pasted on May 21:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(int argc, char **argv)
{
    int i, cnt = 0;
    long n = 27618;//atol(argv[1]);

    time_t t1, t2;

    time(&t1);
    for (i = 2; i < n / i; i++, cnt++)
    {
        while (!n % i)
        {
            puts("WOW");
            n /= i;
            cnt++;
        }
    }
    time(&t2);

    printf("n_ops: %d\n", cnt);
    printf("time taken: %f\n", (double) (t2-t1));

    exit(0);
}


Output:
1
2
n_ops: 164
time taken: 0.000000


Create a new paste based on this one


Comments: