Euler-Mascheroni Constant

From: Felix Tilley (ftilley_at_localhost.localdomain)
Date: 08/25/04

  • Next message: Tauno Voipio: "Re: Need Linux Help"
    Date: Tue, 24 Aug 2004 21:02:46 -0700
    
    

    I have been using gamma, the E-M constant for years as an evaluator of
    computer speeds. You may find it helpful. I also didthis in BASIC and
    FORTRAN many years ago.

    Gamma is approx .5772.

    Please note that gamma is a reserved word in some versions of Linux.

    ==================================================================

    #include "stdio.h"
    #include "math.h"

    /* Compute Euler-Mascheroni Constant, approx 0.5772 */

    main (argc, argv)

    int argc; char *argv[];
    {
    long m,n,i,j;
    double gamma1,sum1=0.0;

    char sdate[256], sptr;
    char *whatIDstring="\n@(#) Euler-Mascheroni constant 18 JAN 2002\n";

    strncpy (sdate, "\nEuler-Mascheroni constant\nCompiled ", 64);
    strncat (sdate, __DATE__, 32);
    strcat (sdate, " ");
    strncat (sdate, __TIME__, 32);
    strcat (sdate, " -0700");

    printf ("%s\n", sdate );

    if (argc >1)
    m=atoi(argv[1]);
    else
    {
      printf("\nEuler-Mascheroni: Enter m ");
      scanf ("%ld", &m);
    }

    for (n=m; n>0; n--) /* Infinite summation (1/n) */
      sum1 += 1.0/n;

    gamma1 = sum1 - log(m);
    printf("\n\n m sum gamma\n\n%ld %3.12lf %2.12lf\n", m,sum1, gamma1);

    exit (0);
    }

    -- 
    Felix Tilley
    Rank: MAJ
    Fanatic Lartvocate
    FL# 555-LART
    

  • Next message: Tauno Voipio: "Re: Need Linux Help"