Advertisement
Guest User

GCD in Scala (copied from worksheet)

a guest
Nov 27th, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.24 KB | None | 0 0
  1. object GCD
  2. {
  3.     def GCD(a: Int,b: Int): Int = {
  4.        if(b==0) a else GCD(b, a%b)
  5.     }                                             //> GCD: (a: Int, b: Int)Int
  6.      
  7.     GCD(21,14)                                    //> res0: Int = 7
  8. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement