Advertisement
Guest User

Untitled

a guest
Dec 14th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. class Ulamek(x: Int, y: Int) {
  2. require(y != 0)
  3.  
  4. private val g = gcd(x, y)
  5. val licznik : Int = x / g
  6. val mianownik : Int = y / g
  7.  
  8. private def gcd(a: Int, b: Int) : Int =
  9. if (b == 0) a else gcd(b, a % b)
  10.  
  11. override def toString =
  12. licznik + "/" + mianownik
  13. }
  14.  
  15. def main() = {
  16. val f = new Ulamek(25, 100)
  17. println(f)
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement