solutions1/collatz.scala
changeset 320 cdfb2ce30a3d
parent 282 ec9773fe1dc0
child 335 7e00d2b13b04
equal deleted inserted replaced
319:b84ea52bfd8f 320:cdfb2ce30a3d
    15 def collatz_max(bnd: Long): (Long, Long) = {
    15 def collatz_max(bnd: Long): (Long, Long) = {
    16   val all = for (i <- (1L to bnd)) yield (collatz(i), i)
    16   val all = for (i <- (1L to bnd)) yield (collatz(i), i)
    17   all.maxBy(_._1)
    17   all.maxBy(_._1)
    18 }
    18 }
    19 
    19 
       
    20 //collatz_max(1000000)
       
    21 //collatz_max(10000000)
       
    22 //collatz_max(100000000)
    20 
    23 
    21 /* some test cases
    24 /* some test cases
    22 val bnds = List(10, 100, 1000, 10000, 100000, 1000000)
    25 val bnds = List(10, 100, 1000, 10000, 100000, 1000000)
    23 
    26 
    24 for (bnd <- bnds) {
    27 for (bnd <- bnds) {