-
Notifications
You must be signed in to change notification settings - Fork 0
The Maths Standard Library
C272 edited this page Dec 18, 2019
·
5 revisions
Contains most core mathematical functions and libraries for Algo.
Generates a random integer between the max negative INT32
and the max positive INT32
value.
Parameters:
No parameters.
Usage:
let x = maths.random.int();
print x; //random.
Generates a random integer between the given values (the values must be between the max negative INT32
and the max positive INT32
).
Parameters:
Name | Description |
---|---|
min | The minimum value to generate. |
max | The maximum value to generate. |
Usage:
x = maths.random.intRange(0, 10); //generates a number between 0 and 10
print x;
Raises a base value to a power, then performs a modulus on that value. Useful when values become too large to process.
Parameters:
Name | Description |
---|---|
base | The base number to apply the modPow to. |
pow | The power to raise to. |
mod | The value to modulus by. |
Usage:
x = modPow(3, 213, 2); //same as 3^213 % 2
Checks whether a number is prime using the Miller-Rabin primality test, given a certainty.
Parameters:
Name | Description |
---|---|
num | The number to check for primality. |
cert | The certainty value. 5 is usually fine. |
Usage:
print maths.isPrime(5, 5); //true
print maths.isPrime(20, 5); //false
Algo (c) Larry Tang, 2019.
Commercial use of Algo must include the LICENSE
file in the same directory as the executable.
Standard Library Documentation: