Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <vc7nb0$7rl3$1@paganini.bofh.team>
Deutsch   English   Français   Italiano  
<vc7nb0$7rl3$1@paganini.bofh.team>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!npeer.as286.net!npeer-ng0.as286.net!3.eu.feeder.erje.net!feeder.erje.net!newsfeed.bofh.team!paganini.bofh.team!not-for-mail
From: Student Project <student@invalid.invalid>
Newsgroups: alt.comp.lang.c, comp.lang.c
Subject: A very slow program
Date: Sun, 15 Sep 2024 22:45:59 +0000
Organization: To protect and to server
Message-ID: <vc7nb0$7rl3$1@paganini.bofh.team>
Mime-Version: 1.0
Content-Type: text/plain;
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 15 Sep 2024 22:33:05 -0000 (UTC)
Injection-Info: paganini.bofh.team; logging-data="257699"; posting-host="ik8YFCuVdFDMks72ULyevQ.user.paganini.bofh.team"; mail-complaints-to="usenet@bofh.team"; posting-account="9dIQLXBM7WM9KzA+yjdR4A";
X-Notice: Filtered by postfilter v. 0.9.3
Content-Language: en
Bytes: 1787
Lines: 38

#include <time.h>
#include <stdio.h>

#define RUNS 1000
#define SIZE 1000000

int mark[SIZE];

int main(void)
{
     time_t start, finish;
     int i, loop, n, num;

     time(&start);

     /*  This loop finds the prime numbers between 2 and SIZE   */
     for (loop = 0; loop < RUNS; ++loop)
     {
         for (n = 0; n < SIZE; ++n)
             mark[n] = 0;
         /*  This loops marks all the composite numbers with -1  */
         for (num = 0, n = 2; n < SIZE; ++n)
             if (!mark[n])
             {
                 for (i = 2 * n; i < SIZE; i += n)
                     mark[i] = -1;
                 ++num;
             }
     }
     time(&finish);
     printf("Program takes an average of %f seconds "
            "to find %d primes.\n",
            difftime(finish, start) / RUNS, num);
}
/*
The result on my slow machine:
Program takes an average of 0.018000 seconds to find 78498 primes.
*/