/******************************************************************************/
/* */
/* FILE: may.cpp */
/* */
/* This program computes quite a famous C++ constant */
/* ================================================= */
/* */
/* It is based on an idea from PHILIPPE SEEWER (http://www.sws.bfh.ch) */
/* */
/* Compiled and tested with Visual C++ V6.0 */
/* */
/* V1.00 31-MAY-2001 P. Tellenbach http://www.heimetli.ch/ */
/* */
/******************************************************************************/
#include <iostream>
class Computer
{
protected:
static Computer *list ;
Computer *next ;
double value ;
double func( double n )
{
if( next )
return value + n * next->func( n ) ;
return value ;
}
public:
Computer( double val ) : value(val)
{
next = list ;
list = this ;
}
static double compute( double n )
{
return list->func( n ) ;
}
} ;
Computer *Computer::list = NULL ;
int main( )
{
Computer( -0.0000199493478221892 ) ;
Computer( 0.00170801522349198 ) ;
Computer( -0.0652646127594653 ) ;
Computer( 1.46796617521522 ) ;
Computer( -21.5819612576657 ) ;
Computer( 217.713509399792 ) ;
Computer( -1538.60419552855 ) ;
Computer( 7635.50553541271 ) ;
Computer( -26240.4880212878 ) ;
Computer( 60422.8402050241 ) ;
Computer( -87602.3794713755 ) ;
Computer( 70841.9748145348 ) ;
Computer( -23687.3847948726 ) ;
Computer( 72.5 ) ;
for( int i = 0; i < 14; i++ )
std::cout << (char) Computer::compute( i ) ;
return 0 ;
}
Update 31. May 2021
This program still compiles and runs without any changes.