is.power | R Documentation |
Determine whether the given integer is a square number, a cube number, or a power of an integer.
is.square(n)
is.cube(n)
is.power(n)
n |
A single integer. |
is.square(n)
returns TRUE
if n
is a square number, that is, n = m^2
for some integer m
,
and returns FALSE
otherwise.
is.cube(n)
returns TRUE
if n
is the cube of an integer, n = m^3
for some integer m
,
and returns FALSE
otherwise.
is.power(n)
returns TRUE
if n
is an integer power of an integer, n = m^k
for some integers
m
and k
, and returns FALSE
otherwise.
These functions use the prime factorisation of n
and may be more reliable than testing where sqrt(n)
is an
integer, etc.
Negative values of n
are permitted.
A single logical value.
.
primefactors
is.square(9)
is.cube(9)
is.cube(27)
is.cube(-27)
is.power(27)
is.power(3^5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.