Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi. for this problem we have to do it in DrRacket (Not Java but like Lisp-Scheme

ID: 3785677 • Letter: H

Question

Hi. for this problem we have to do it in DrRacket (Not Java but like Lisp-Scheme family)

The famous computer scientist, Edsger Dijkstra, made the
following observations for m and n >= 1:

1. If m = n, then the greatest common divisor of m and n is m.
2. If m > n, then the greatest common divisor of m and n is
   the greatest divisor of m-n and n.

Based on these observations, implement a function to compute
the greatest common divisor of two given numbers >= 1. Follow
all the steps of the design recipe.

and write the termination argument and check-expect.

Explanation / Answer

Racket is functional programming which uses prefix notation

(define (gcd a b)

( if ( = b 0)

a

(gcd b (modulo a b))))

This function will return the gcd of the given two numbers a,b ... it uses recursion and if b=0 returns a or else it will make a call to the same function with the parameters b, a%b .....

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote