object Main { def main(args: Array[String]) { val sc = new java.util.Scanner(System.in) val A, B = sc.nextInt def isMatch(n: Int): Boolean = { if (n % 3 == 0) return true return n.toString.exists(_ == '3') } val xs = (A to B).filter(isMatch) xs.foreach(println) } }