12. Perfect power | R Documentation |
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).
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)
x |
object of class vli or 32 bits integer |
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.
is.perfectpow(x)
returns a Boolean
perfectpow(x)
returns a list of two objects of class vli
Javier Leiva Cuadrado
x <- as.vli("234925792")
is.perfectpow(x)
x <- as.vli("77808066022325383192121677734375")
is.perfectpow(x)
res <- perfectpow(x)
res
res[[1]]^res[[2]]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.