Add: program: words version 1
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
#include "crypto.h"
|
||||
|
||||
int lcg(int seed)
|
||||
{
|
||||
int x = seed;
|
||||
|
||||
// Constants (ZX81 LCG)
|
||||
int a = 75;
|
||||
int c = 74;
|
||||
long m = 65537;
|
||||
|
||||
for (int i=0; i<10; i++)
|
||||
{
|
||||
x = (a*x + c) % m;
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
int randint(int seed)
|
||||
{
|
||||
int x = lcg(seed);
|
||||
return x;
|
||||
}
|
||||
|
||||
9
src/libc/crypto.h
Normal file
9
src/libc/crypto.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef CRYPTO_H
|
||||
#define CRYPTO_H
|
||||
|
||||
#define RAND_MAX 1024
|
||||
|
||||
int lcg(int seed);
|
||||
int randint(int seed);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user