Last data update: 2014.03.03

R: Greatest Common Divisor
GCD.qR Documentation

Greatest Common Divisor

Description

Finds the greatest common divisor (GCD) of two integers using the Euclidean algorithm. In addition to the value of GCD, it generates the number of required iterations to find GCD and the sequence of partial quotients.

Usage

GCD.q(x, y)

Arguments

x

the first integer greater than zero.

y

the second integer greater than zero.

Value

k

the number of required iterations to find GCD.

q

the sequence of partial quotients.

g

the value of greatest common divisor.

Author(s)

Haydar Demirhan

Maintainer: Haydar Demirhan <haydarde@hacettepe.edu.tr>

Examples

result=GCD.q(4535,2451)
print(result)

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

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(CryptRndTest)
Loading required package: MissMech
Loading required package: kSamples
Loading required package: SuppDists
Loading required package: sfsmisc
Loading required package: Rmpfr
Loading required package: gmp

Attaching package: 'gmp'

The following objects are masked from 'package:sfsmisc':

    factorize, is.whole

The following objects are masked from 'package:base':

    %*%, apply, crossprod, matrix, tcrossprod

C code of R package 'Rmpfr': GMP using 64 bits per limb


Attaching package: 'Rmpfr'

The following objects are masked from 'package:stats':

    dbinom, dnorm, dpois, pnorm

The following objects are masked from 'package:base':

    cbind, pmax, pmin, rbind

Loading required package: parallel
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/CryptRndTest/GCD.q.Rd_%03d_medium.png", width=480, height=480)
> ### Name: GCD.q
> ### Title: Greatest Common Divisor
> ### Aliases: GCD.q
> 
> ### ** Examples
> 
> result=GCD.q(4535,2451)
> print(result)
$k
[1] 7

$q
[1]  1  1  5  1  2  9 13

$g
[1] 1

> 
> result=GCD.q(35,2)
> print(result)
$k
[1] 2

$q
[1] 17  2

$g
[1] 1

> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>