From b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b Mon Sep 17 00:00:00 2001 From: priyanka Date: Wed, 24 Jun 2015 15:03:17 +0530 Subject: initial commit / add all books --- 37/CH1/EX1.5/Solved5.sci | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 37/CH1/EX1.5/Solved5.sci (limited to '37/CH1/EX1.5') diff --git a/37/CH1/EX1.5/Solved5.sci b/37/CH1/EX1.5/Solved5.sci new file mode 100755 index 000000000..259e2b86c --- /dev/null +++ b/37/CH1/EX1.5/Solved5.sci @@ -0,0 +1,24 @@ +//Solved Example 7: +//Reducing The Given Rational Number +funcprot(0) +function[y]=reduce(nm,dn) +rational1=struct('numerator',nm,'denominator',dn) +y=0 +if(rational1.numerator>rational1.denominator) + a=rational1.numerator; + b=rational1.denominator; +else + a=rational1.denominator; + b=rational1.numerator; +end +while(b~=0) + rem=modulo(a,b); + a=b; + b=rem; +end +y=struct('numerator',nm/a,'denominator',dn/a); +disp(y); +endfunction +nm=22; +dn=44; +y=reduce(nm,dn) \ No newline at end of file -- cgit