R/iteratedLogarithm.r

Defines functions iteratedLogarithm

Documented in iteratedLogarithm

#' Iterated Logarithm (Base 2)
#'
#' This function calculates the number of times the logarithm function (base 2) must be iteratively applied before the result is less than or equal to 1.
#' @param num - An integer.
#' @export iteratedLogarithm
#' @examples
#' iteratedLogarithm(4)
#' 2
iteratedLogarithm <- function(num) {
  if (num<=1) {
    return(0)
  } else {
    iterator=1+iteratedLogarithm(log2(num))
  }
  return (iterator)
}
lashmore/MolEndoMatch documentation built on May 5, 2019, 8:02 p.m.