โ Back to Methods
Question 375
Recursive GCD Method
Recursive GCD Method
Write the static methodGcdso it returns the greatest common divisor of two non-negative integers using the recursive Euclidean algorithm: whenbis0the answer isa, otherwise the answer isGcd(b, a % b). The tester calls it and prints the result. Do NOT write aMainmethod. ForGcd(48, 18)the program prints exactly: 6
Expected Output:
6
Topics:
Methods
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cw, cr, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.