linux build

This commit is contained in:
David Lee 2024-07-04 09:37:15 -07:00
parent 6b06024058
commit 2329ed370e
7 changed files with 12 additions and 145 deletions

12
Microsoft C v1/m.sh Normal file
View File

@ -0,0 +1,12 @@
str=$(tr '[a-z]' '[A-Z]' <<< $1)
rm $str.OBJ 2>/dev/null
rm $str.MAP 2>/dev/null
rm $str.EXE 2>/dev/null
ntvdm -r:. -u mc1 $str
ntvdm -r:. -u mc2 $str
ntvdm -r:. -u link $str + c + gettm,, $str.map, mc
rm $str.OBJ 2>/dev/null
rm $str.MAP 2>/dev/null

View File

@ -1,99 +0,0 @@
#include <stdio.h>
/*
#include <time.h>
#include <stdlib.h>
*/
#ifndef __max
#define __max( a, b ) (a) > (b) ? a : b
#define __min( a, b ) (a) < (b) ? a : b
#endif
typedef /*unsigned*/ long ulong;
ulong gcd( m, n ) ulong m, n;
{
ulong a = 0;
ulong b = __max( m, n );
ulong r = __min( m, n );
while ( 0 != r )
{
a = b;
b = r;
r = a % b;
}
return b;
}
/*
ulong randi()
{
return (ulong) rand() | ( ( (ulong) rand() ) << 16 );
}
*/
/* https://en.wikipedia.org/wiki/Ap%C3%A9ry%27s_theorem */
int first_implementation()
{
ulong total = 1000;
ulong i, iq;
double sofar = 0.0;
ulong prev = 1;
for ( i = 1; i <= total; i++ )
{
iq = i * i * i;
sofar += (double) 1.0 / (double) ( iq );
/*printf( "i, iq, and sofar: %lu, %lu, %lf\n", i, iq, sofar );*/
if ( i == ( prev * 10 ) )
{
prev = i;
printf( " at %12lu iterations: %lf\n", i, sofar );
fflush( stdout );
}
}
}
int main()
{
ulong totalEntries = 100000;
ulong i, prev, totalCoprimes, greatest, a, b, c;
printf( "starting, should tend towards 1.2020569031595942854...\n" );
printf( "first implementation...\n" );
first_implementation();
/* no rand
printf( "second implementation...\n" );
totalCoprimes = 0;
prev = 1;
for ( i = 1; i <= totalEntries; i++ )
{
a = randi();
b = randi();
c = randi();
greatest = gcd( a, gcd( b, c ) );
if ( 1 == greatest )
totalCoprimes++;
if ( i == ( prev * 10 ) )
{
prev = i;
printf( " at %12lu iterations: %lf\n", i, (double) i / (double) totalCoprimes );
fflush( stdout );
}
}
*/
printf( "done\n" );
return 1202;
}

View File

@ -1,46 +0,0 @@
#include <stdio.h>
#define HIGH_MARK 500 /* 2800 */
static long r[HIGH_MARK + 1];
int main() {
long i, k, c;
long b, d;
long iter;
int iterations = 1;
for ( iter = 0; iter < iterations; iter++ ) {
c = 0;
for (i = 0; i < HIGH_MARK; i++) {
r[i] = 2000;
}
for (k = HIGH_MARK; k > 0; k -= 14) {
d = 0;
i = k;
for (;;) {
d += r[i] * 10000;
b = 2 * i - 1;
r[i] = d % b;
d /= b;
i--;
if (i == 0) break;
d *= i;
}
if ( iter == ( iterations - 1 ) )
{
printf( "%.4d", c + d / 10000 );
fflush( stdout );
}
c = d % 10000;
}
}
printf( "\n" );
return 0;
}