R/Calculator.R

Defines functions square cube multiply divide sum subtract

Documented in cube divide multiply square subtract sum

#' Calculate math problems
#'
#' Takes in any numeric value and squares it.
#' @param x A numeric value to be squared.
#' @return The square of the input
#' @export
square <- function(x) {
  return(x^2)
}

#' Cube a number
#' @param x Number to be cubed
#' @return the cube of the input
#' @export
cube <- function(x) {
  return(x^3)
}

#' Multiply a number
#' @param xy Numbers to be muliplied
#' @return The multiple of the inputs
#' @export
multiply <- function(x, y) {
  return(x*y)
}

#' Divide a number
#' @param xy Numbers to be divided
#' @return The product of the inputs
#' @export
divide <- function(x, y) {
  return(x/y)
}

#' Add a number
#' @param xy Numbers to be added
#' @return The sum of the inputs
#' @export
sum <- function(x, y) {
  return(x+y)
}

#' Subtract a number
#' @param xy Numbers to be subtracted
#' @return The subtraction of the inputs
#' @export
subtract <- function(x, y) {
  return(x-y)
}
ozanmirza1/Calculator documentation built on May 24, 2019, 5:56 p.m.