is.power: Recognise a Square, Cube, or Power of an Integer

View source: R/primefactors.R

is.powerR Documentation

Recognise a Square, Cube, or Power of an Integer

Description

Determine whether the given integer is a square number, a cube number, or a power of an integer.

Usage

is.square(n)
is.cube(n)
is.power(n)

Arguments

n

A single integer.

Details

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.

Value

A single logical value.

Author(s)

\adrian

.

See Also

primefactors

Examples

  is.square(9)
  is.cube(9)
  is.cube(27)
  is.cube(-27)
  is.power(27)
  is.power(3^5)

spatstat.utils documentation built on April 12, 2025, 2 a.m.