blob: 3f0b75d2b0544412aadba820b683c5fc6f8be5aa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
//Chapter 04:Number Theory and Cryptography
clc;
clear all;
//GCD using recursion
function f=gcd(n,m)
if (n>=m) & (modulo(n,m)==0) then
f=m
else
f=gcd(m,modulo(n,m))
end
endfunction
a=input("Number 1:")
b=input("Number 2:")
ann=gcd(a,b)
mprintf("GCD(%d,%d) is:%d",a,b,ann)
|