14. Finding a random divisor {VeryLargeIntegers} | R Documentation |
Finding a Random Divisor of a vli Object
Description
divisor
returns a randomly chosen divisor of a given number.
Usage
divisor(n, iter = 100)
## Default S3 method:
divisor(n, iter = 100)
## S3 method for class 'numeric'
divisor(n, iter = 100)
## S3 method for class 'vli'
divisor(n, iter = 100)
Arguments
n |
object of class vli or 32 bits integer |
iter |
number of iterations for testing if the given number is prime; numeric |
Details
The algorithm determines if the given number is prime or composite by usign the Miller-Rabin Probabilistic Primality Test. If it is prime, it returns the number itself. If it is composite, it returns a randomly chosen divisor. The number of iterations is configurable to set the desired accuracy. A too low number of iterations could cause an infinite loop because of being looking for a divisor of a prime number.
Value
object of class vli
Author(s)
Javier Leiva Cuadrado
Examples
r <- rvliprime(100)
r
x <- r * 51
x
divisor(x, iter = 100)
[Package VeryLargeIntegers version 0.2.1 Index]