expScale <- function(min, max, time=12L, round=10L) {
  if (time < 1)
    stop("time cannot be less than 1")
  if (!is.integer(round))
    stop("round should be an integer")

  # find C, 
  ## which is the (time-1) root of ln(min^time / max)
  target <- log((min^time) / max)

# browser()

  min <- 10
  max <- 25
  log(min)
  log(max)

  init <- log(min)
  i <- 0


  i <- 14
  C <- 0
  while (i >= (-round)) {
    C <- C + max(which( log((C + 0:10 * (10^i))^(time-1)) < target) - 1) * 10^i
    i <- i - 1
  }

  ## Check percent of error
  stopifnot(abs((C ^ (time - 1)) - target) / target < 0.0000005)

  x <- log(min / C)

  cat("\nC * e ^ (12 x)\nC = ", C, "\nx = ", x, "\n")

  return(invisible(list(C=C, x=x)))
}


# expScale(20, 50, time=50) -> Cx
# Cx$C * exp(Cx$x * (1:50))
# Cx$C * exp(Cx$x * (1:50)) %>% sum