```      //  TAU.C
//  Calculates the value of tau
//  Author: Peter Meyer
//  Last mod.: 1999-01-12

#include <string.h>
#include <stdio.h>
#include <math.h>

char buff[256];
char temp[16];

double tau(int m);

/*----------------------------*/
void main(int argc,char *argv[])
{
int i, n=22, m=2;
char *ptr1, *ptr2;
double t0, t1;

printf("\nThis program calculates tau to 16 decimal places thus:"
"\ntau = sqrt(1 + sqrt(2 + sqrt(3 + sqrt(4 + ... + sqrt(22)))...)))");

t1 = 0;
do  {
t0 = t1;
t1 = tau(m++);
printf("\n%18.16f = ",t1);
strcpy(buff,"sqrt(1+");
for ( i=2; i<=m-1; i++ )
{
sprintf(temp,"sqrt(%d+",i);
strcat(buff,temp);
}
sprintf(temp,"sqrt(%d)",m);
strcat(buff,temp);
for ( i=2; i<=m; i++ )
strcat(buff,")");
if ( strlen(buff) > 55 )
{
ptr1 = strrchr(buff,'+');
*(ptr1-1) = 0;
buff[79-21-strlen(ptr1)-3] = 0;
ptr2 = strrchr(buff,'+');
*(ptr2+1) = 0;
strcat(buff,"...");
strcat(buff,ptr1);
}
printf("%s",buff);
} while ( t1 != t0 );
printf("\n");
}

/*-------------*/
double tau(int m)
{
int i;
double x;

x = sqrt(m);
for ( i=m-1; i>=1; i-- )
x = sqrt(i + x);

return ( x );
}
```