-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutilities.h
More file actions
22 lines (16 loc) · 821 Bytes
/
utilities.h
File metadata and controls
22 lines (16 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
* Header file with prototypes of userful functions.
* Definition of that function can be found in utilities.cpp
*
*/
// GCD of two positive integers using Euclidian algorithm
int gcd(int x, int y);
// Compute and return a^(-1) mod b using extended Euclidian algorithm.
// Precondition: a and b must be positive integers that are co-prime and b > 1.
int inverse_modulo(int a, int b);
// compute and return base^exponent % mod.
// Parameters base, exponent and mod must be positive whole numbers.
unsigned long power_modulo(unsigned long base, unsigned long exponent, unsigned long mod);
// generate pseudorandom positive integer from range [min, max] (min and max are included).
// Parameters min and max must be positive whole numbers.
unsigned long genPseudoRandomInt(unsigned long min, unsigned long max);