R/euclidean.r

Defines functions euclidean

Documented in euclidean

#'@title Euclidean
#'
#'@description  Euclidean algorithm finds highest common factor of two natural numbers.
#'
#'@param a natural_number
#'@param b natural_number
#'
#'@return Factor variable
#'
#'@examples
#'euclidean(123612, 13892347912)
#'euclidean(100, 1000)
#'
#'@references https://en.wikipedia.org/wiki/Euclidean_algorithm
#'@export


euclidean <-
function(a,b){
       while(b!=0)
       {
         stopifnot(is.numeric(a)&is.numeric(b))
         t<-b
         b<-a%%b
         a<-t
       }
       return(a)
}
dimitramuni/euclidijk documentation built on Nov. 4, 2019, 10:31 a.m.