Learn R Programming

Peacock.test (version 1.0)

gcd: Greatest Common Divisor

Description

This function returns the greatest common divisor of two integers

Usage

gcd(x, y)

Arguments

x
a nonnegative integer
y
a nonnegative integer

Value

An integer, which is the greatest common divisor. If both arguments are zero, then the returned value is 1.

Details

The function utilizes the Euclidean algorithm to compute the greatest common divisor of two integers

Examples

Run this code
x <- 4
y <- 6
d <- gcd(x, y)
d

Run the code above in your browser using DataLab