divisor: Finding a Random Divisor of a vli Object

View source: R/divisor.R

14. Finding a random divisorR 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)

VeryLargeIntegers documentation built on May 31, 2023, 7:06 p.m.