variables - Time complexity of this testing algorithm? -


what worst case scenario , how improve while statement?

main() {

 clock_t tic = clock();     int n, i, j;    int *p;    scanf("%d",&n);    p=&n;    printf("1 \n");    getchar();    for(i=2; i-*p; i++)       {             j=2;             while(j<(int)sqrt((double)i)+1)                          if(i % j) j++;                 else j=(int)sqrt((double)i)+3;                 if(j!=(int)sqrt((double)i)+3)             printf("%d \n",i);             }             clock_t toc = clock();             printf("elapsed: %f seconds\n", (double)(toc - tic) / clocks_per_sec);             getchar();                                }  


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -