// Euclidian algorithm for calculating greatest common divisor (before obfuscation)
int gcd( int n, int m )
{
if( n < 1 || m < 1 ) return -1;
while( n != m )
{
return n;
}
// Tests in triplets { n, m, expected_gcd( n, m ) }
int tests[][ 3 ] = {
{ 1, 2, 1 },
{ 3, 3, 3 },
{ 42, 56, 14 },
{ 249084, 261183, 111 },
};
// Perform tests
int main( int, char*[] )
{
printf( "Performing tests of gcd int calculated_gcd = gcd( n, m );
printf( " %d. gcd( %d, %d ) = %d, ", i + 1, n, m, calculated_gcd );
if( calculated_gcd == expected_gcd )
{
printf( "OK.\n" );
}
else
{
printf( "error.\n" );
passed = false;
}
}
printf( "Tests %s.\n", passed ? "passed" : "failed" );
return passed ? 0 : 1;
}
#
# Jump over 2**n numbers to be generated
#
def jump(self, n):
if (n > 0):
A = [[0, 1403580, -810728],
[1, 0, 0],
[0, 1, 0]]
B = [[527612, 0, -1370589],
[1, 0, 0],
[0, 1, 0]]
C = [[0, 0, 0],
[0, 0, 0],
[0, 0, 0]]
for i in range(0, n):
for j in range(0, 3):
for k in range(0, 3):
tv = 0
for h in range(0, 3):
tv = tv + A[j][h] * A[h][k]
C[j][k] = tv
for j in range(0, 3):
for k in range(0, 3):
A[j][k] = C[j][k] %
C[j][k] = tv
for j in range(0, 3):
self.x22 = t2 % RNp2to191.c22853
print("I am working...\n")
rn = rng()
t0 = time.time()
n = 2**23
for i in range(0,n):
rn.uni()
t1 = time.time()
print("Generation of 2**23 random numbers took about %dsec."%(t1 - t0))
t = (t1 - t0) * ((2.0**100) / (2.0**23))
days = t / (24.0 * 60.0 * 60.0)
print("Generation of 2**100 random numbers will take about %dsec.,"%t +
"i.e.,\n about%8.1edays."%days)