The Computer Language
24.04 Benchmarks Game

too simple C clang program

source code

/* The Computer Language Benchmarks Game
   https://salsa.debian.org/benchmarksgame-team/benchmarksgame/
*/

#include<stdio.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
    long n = atol(argv[1]);
    double sum = 0.0;
    double flip = -1.0;
    for (long i = 1; i <= n; i++) {    
        flip *= -1.0;        
        sum += flip / (2*i - 1);               
    }                        
    printf("%.9f\n", sum*4.0);
    return 0;      
}
    

notes, command-line, and program output

NOTES:
64-bit Ubuntu quad core
Ubuntu clang version 17.0.2


 Fri, 08 Mar 2024 02:17:14 GMT

MAKE:
/usr/bin/clang -pipe -Wall -O3 -fomit-frame-pointer -march=ivybridge  toosimple.c -o toosimple.clang_run 
rm toosimple.c

4.42s to complete and log all make actions

COMMAND LINE:
 ./toosimple.clang_run 10000000000

PROGRAM OUTPUT:
3.141592653