Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

IsIntpower

Powers of Integers


Description

Determine whether p is the power of an integer.

Usage

isIntpower(p)

Arguments

p

any integer number.

Details

Determines whether p is the power of an integer and returns a tupel (n, m) such that p=n^m where m is as small as possible. E.g., if p is prime it returns c(p,1).

Value

A 2-vector of integers.

Examples

isIntpower(1)    #  1  1
isIntpower(15)   # 15  1
isIntpower(17)   # 17  1
isIntpower(64)   #  8  2
isIntpower(36)   #  6  2
isIntpower(100)  # 10  2
## Not run: 
  for (p in 5^7:7^5) {
      pp <- isIntpower(p)
      if (pp[2] != 1) cat(p, ":\t", pp, "\n")
  }
## End(Not run)

numbers

Number-Theoretic Functions

v0.8-1
GPL (>= 3)
Authors
Hans Werner Borchers
Initial release
2021-04-11

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.