R/euclidean.R

Defines functions euclidean

Documented in euclidean

#' Euclidean algorithm
#'
#' @param a An integer
#' @param b An integer
#' @return The greatest common divisor of \code{a} and \code{b}
#' @description Euclidian algorithm to find the greatest common divisor of two numbers
#' @author Simon and Mohamed
#' @examples
#' euclidean(123612, 13892347912)
#' euclidean(100, 1000)
#' @references \url{https://en.wikipedia.org/wiki/Euclidean_algorithm}
#' @export
euclidean <- function(a, b) {
  while(b != 0) {
    t <- b
    b <- a %% b
    a <- t
  }
  return(a)
}
Elmahi92/smplab documentation built on Dec. 17, 2021, 6:28 p.m.