<< NARVAL_S_Gcd NARVAL NARVAL_S_GcdRec >>

NARVAL >> NARVAL > NARVAL_S_GcdIter

NARVAL_S_GcdIter

Perform the greatest common divisor between two integers (Iterative Euclidian algorithm).

Calling Sequence

[g] = NARVAL_S_GcdIter(a,b)

Parameters

a :

integer.

b :

integer.

g :

greatest common divisor.

Description

NARVAL_S_GcdIter performs the greatest common divisor (GCD) g of the two integers a and b in respect with the Iterative Euclidian algorithm (WIKIPEDIA).

Pseudo-Code (Wikipedia)

function gcd(a, b)
    if a = 0
       return b
    while b  0
        if a > b
           a := a  b
        else
           b := b  a
    return a

Examples

a=136;//integer
b=867;//integer
[g]=NARVAL_S_GcdIter(a,b);//application of NARVAL_S_GcdIter
g
a=10;//integer
b=3;//integer
[g]=NARVAL_S_GcdIter(a,b);//application of NARVAL_S_GcdIter
g

Authors

Foued Melakessou

Contact

Dr. Foued Melakessou

Research Associate

Interdisciplinary Centre for Security, Reliability and Trust

Room F106

University of Luxembourg

6, rue Coudenhove Kalergi

L-1359 Luxembourg-Kirchberg

E-mail: foued.melakessou@uni.lu

Tel: (+352) 46 66 44 5346

Home Page


<< NARVAL_S_Gcd NARVAL NARVAL_S_GcdRec >>