Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MATLAB question: Write a recursive function getGCD to calculate the greatest common denominator of two given numbers. For example. getGCD(12, 9) = 3. The function

MATLAB question:

image text in transcribed

Write a recursive function getGCD to calculate the greatest common denominator of two given numbers. For example. getGCD(12, 9) = 3. The function should have the following declaration: function gcd = getGCD(n1, n2) where inputs n1 and n2 are positive integers and output gcd is the greatest common denominator of n1 and n2. The function should have a description. When the inputs are not positive integers, set the output to be a string 'Error' and use return to exit the function. (a) Set p4a = evalc('help getGCD'). (b) Find the greatest common denominator of -232432 and 345525. Put the answer to p4b. (c) Find the greatest common denominator of 0 and 345525. Put the answer to p4c. (d) Find the greatest common denominator of 0 and -232432. Put the answer to p4d. (e) Find the greatest common denominator of 525 and 345525. Put the answer to p4e

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions