Learn R Programming

CryptRndTest (version 1.2.2)

GCD: Greatest Common Divisor

Description

Finds the greatest common divisor (GCD) of two integers using a recursive approximation. In addition to the value of GCD, it generates the number of required iterations to find GCD.

Usage

GCD(x, y, k = 0)

Arguments

x
the first integer greater than zero.
y
the second integer greater than zero.
k
initial value for counting the number of steps. It must be set zero.

Value

k
the number of required iterations to find GCD.
g
the value of greatest common divisor.

Examples

Run this code
result=GCD(4535,2451)
print(result)

result=GCD(35,2)
print(result)

Run the code above in your browser using DataLab