01-TwoBases.scala 316 B

123456789101112
  1. object TwoBases {
  2. def test(x: Int, y: Int, z: Int) =
  3. (100*x + 10*y + z == math.pow(9,2)*z + 9*y + z)
  4. def main(args: Array[String]) {
  5. for(x <- 0 to 9; y <- 0 to 9; z <- 0 to 9) {
  6. if(test(x, y, z)){
  7. println("%d%d%d".format(x, y, z));
  8. }
  9. }
  10. }
  11. }