summaryrefslogtreecommitdiff
path: root/3808/CH5/EX5.4
diff options
context:
space:
mode:
Diffstat (limited to '3808/CH5/EX5.4')
-rw-r--r--3808/CH5/EX5.4/Ex5_4.sce23
1 files changed, 23 insertions, 0 deletions
diff --git a/3808/CH5/EX5.4/Ex5_4.sce b/3808/CH5/EX5.4/Ex5_4.sce
new file mode 100644
index 000000000..14e171890
--- /dev/null
+++ b/3808/CH5/EX5.4/Ex5_4.sce
@@ -0,0 +1,23 @@
+//Chapter 05: Induction and Recursion
+
+clc;
+clear;
+
+function res=greatestcommondivisior(a,b)
+ if a==0 then
+res=b
+ else
+res=greatestcommondivisior(modulo(b,a),a)
+ end
+return res
+endfunction
+
+num1=input("Enter the first number:")
+num2=input("Enter the second number:")
+res_gcd=greatestcommondivisior(num1,num2)
+mprintf("The gcd of %d , %d is %d",num1,num2,res_gcd)
+
+//By Using the inbuilt function,that is provided by Scilab
+p=[num1,num2]
+res=gcd(p)
+mprintf("\nThe gcd of %d , %d is %d",num1,num2,res)