Skip to content

Instantly share code, notes, and snippets.

@softberries
Created February 16, 2019 09:07
Show Gist options
  • Save softberries/7d9c45ac33c336961ddbd3a1a0db2ba2 to your computer and use it in GitHub Desktop.
Save softberries/7d9c45ac33c336961ddbd3a1a0db2ba2 to your computer and use it in GitHub Desktop.
import java.util.concurrent.ThreadLocalRandom
val random: ThreadLocalRandom = ThreadLocalRandom.current()
def getNumber(): (Int, Int) = {
val n = random.nextLong(1,100)
val d = random.nextLong(1,10)
if(n % d == 0 && n / d < 11 && n != d) (n.toInt, d.toInt)
else getNumber()
}
(1 to 100).foreach { _ =>
val nums = getNumber
println(nums._1 + " / " + nums._2 + " = ......")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment