perfectpow: Perfect Power Tools for vli Objects

View source: R/perfectpow.R

12. Perfect powerR Documentation

Perfect Power Tools for vli Objects

Description

A positive integer is a perfect power if it can be expressed as an integer power of another positive integer. That is, a positive integer x is a perfect power if there exist two positive integers a and b such that x = a^b (note that a and b might not be unique).

Usage

perfectpow(x)

## Default S3 method:
perfectpow(x)

## S3 method for class 'numeric'
perfectpow(x)

## S3 method for class 'vli'
perfectpow(x)

is.perfectpow(x)

## Default S3 method:
is.perfectpow(x)

## S3 method for class 'numeric'
is.perfectpow(x)

## S3 method for class 'vli'
is.perfectpow(x)

Arguments

x

object of class vli or 32 bits integer

Details

The function is.perfectpow(x) returns TRUE if there exist two positive integers a and b such that x = a^b, and returns FALSE if there not exist.

The function perfectpow(x) returns a list of two vli objects, a and b, such that x = a^b. If there not exist such numbers, the two vli objects will be equal to zero. Although the concept is usually defined only for positive integers, the function has been also programmed to work with negative integers.

Value

is.perfectpow(x) returns a Boolean

perfectpow(x) returns a list of two objects of class vli

Author(s)

Javier Leiva Cuadrado

Examples

x <- as.vli("234925792")
is.perfectpow(x)

x <- as.vli("77808066022325383192121677734375")
is.perfectpow(x)
res <- perfectpow(x)
res
res[[1]]^res[[2]]

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