The code below creates a function that produces a plot of both the differences between ascending unique differences between perfect powers, and the logarithm of these differences also
CatalanFunction <- function(n){
vector <- c()
vector1 <- c()
for(i in 1:n){
for(j in 1:n){
vector <- c(vector, i^j)
}
vector1 <- c(vector1, vector)
}
vector1 <- unique(sort(vector1, decreasing = FALSE))
vector1 <- diff(vector1, lag = 1)
vector2 <- c(1:length(vector1))
vector3 <- log(vector1)
par(mfrow = c(1, 2))
plot(vector2, vector1, xlab = "nth value", ylab = "nth difference between unique perfect powers")
plot(vector2, vector3, xlab = "nth value", ylab = "log(nth difference between unique perfect powers)")
}
The following example provides the plot for the first 20 integers
CatalanFunction(n = 20)