Saturday, October 4, 2008

One of the programming challenges we always face

While at work, I usually try out a lot of things , Today for a good hash I needed a prime number which has more bits on in the 2nd word ,  that too mainly in the last 4 bits of the 16 bit double byte.


Well, there is this site

which I  came across , where you can ask them to mail a list of prime numbers between one range to the other, also there is a tester in the site, with the current rate of network  usage and so many people producing too much content we will soon run out  of area and then junk will be cleaned up , till then this site hidden in the mass of junk sites might get some prominence, at least that will keep these guys to atleast maintain the site in the long run.

Even I am trying to get adsense to pay up for my domain name ( registration costs at around 400 pm ) .



Well, I can always write a small junky code any time of the day to get it done, but my algo is taking a lot of time, definitely because there is not smart work done in my case ( like eliminating all the even numbers etc )


#include <stdio.h>

#include <stdlib.h>




int main(int argc,char** argv) {

int count = 0;

int j,k;

for ( k = 60200; k < 1000000; k++) {

for ( j  =1 ; j<= (k/2)+1; j++)  {

        if ( j == k) break;

         /*printf("j = %d, i = %d\n", j,i);  */

        if ( (k % j) == 0) count++;


if (count == 1) printf(" %d is a prime number\n", k);







No comments: