Skip to content

Instantly share code, notes, and snippets.

@MishaelRosenthal
Created December 7, 2022 05:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MishaelRosenthal/764af94ff0819a9d8a23e7c48854964f to your computer and use it in GitHub Desktop.
Save MishaelRosenthal/764af94ff0819a9d8a23e7c48854964f to your computer and use it in GitHub Desktop.
import scala.annotation.tailrec
@tailrec
def gcd(a: Int, b: Int): Int = if(b == 0) a else gcd(b, a % b)
val a = 30
val b = 48
println(s"The gcd of $a, $b is ${gcd(a, b)}.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment