solutions1/collatz.scala
changeset 336 25d9c3b2bc99
parent 335 7e00d2b13b04
equal deleted inserted replaced
335:7e00d2b13b04 336:25d9c3b2bc99
    39   if (is_hard(n)) n else
    39   if (is_hard(n)) n else
    40     if (n % 2 == 0) last_odd(n / 2) else 
    40     if (n % 2 == 0) last_odd(n / 2) else 
    41       last_odd(3 * n + 1)
    41       last_odd(3 * n + 1)
    42 
    42 
    43 
    43 
    44 //for (i <- 1 to 130) println(s"$i: ${last_odd(i)}")
    44 //for (i <- 130 to 10000) println(s"$i: ${last_odd(i)}")
       
    45 for (i <- 1 to 100) println(s"$i: ${collatz(i)}")
    45 
    46 
    46 }
    47 }
    47 
    48 
    48 
    49 
    49 
    50