<< NL_S_GCDExtended NL_S: Security NL_S_GCDRecursive >>

NARVAL >> NL_S: Security > NL_S_GCDIterative

NL_S_GCDIterative

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

Calling Sequence

[G] = NL_S_GCDIterative(A,B)

Arguments

A :

Integer.

B :

Integer.

G :

Greatest common divisor.

Description

NL_S_GCDIterative 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]=NL_S_GCDIterative(a,b)//application of NL_S_GCDIterative
a=10;//integer
b=3;//integer
[g]=NL_S_GCDIterative(a,b)//application of NL_S_GCDIterative

Report an issue
<< NL_S_GCDExtended NL_S: Security NL_S_GCDRecursive >>