Executes a Miller-Rabin primality test or generates a probable prime number based on the specified action. If the action is "test", it determines whether the provided number is a prime. If the action is "genprime", it generates a probable prime number with the specified bit length.
Executes a Miller-Rabin primality test or generates a probable prime number based on the specified action. If the action is "test", it determines whether the provided number is a prime. If the action is "genprime", it generates a probable prime number with the specified bit length.
Value parameters
action
A string specifying the operation to perform. Valid values are "test" for performing a primality test or "genprime" for prime number generation.
number
A string representation of the number to test or the bit length for prime generation. For the "test" action, this should be the number to be tested for primality. For the "genprime" action, this should specify the number of bits for the generated prime.
Attributes
Returns
A string result. If the action is "test", returns "PRIME" if the number is a probable prime or "COMPOSITE" otherwise. If the action is "genprime", returns the generated probable prime as a string. If the action is invalid, returns a message indicating the invalid action.