Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Ulamek(x: Int, y: Int) {
- require(y != 0)
- private val g = gcd(x, y)
- val licznik : Int = x / g
- val mianownik : Int = y / g
- private def gcd(a: Int, b: Int) : Int =
- if (b == 0) a else gcd(b, a % b)
- override def toString =
- licznik + "/" + mianownik
- }
- def main() = {
- val f = new Ulamek(25, 100)
- println(f)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement