testing1/collatz.scala
changeset 171 4c9497ab5caa
parent 167 349d706586ef
child 197 c3e39fdeea3b
equal deleted inserted replaced
170:37b1bfcdba79 171:4c9497ab5caa
    19 
    19 
    20 
    20 
    21 }
    21 }
    22 
    22 
    23 
    23 
       
    24 def Collat(n: Long, r: Int = 1) : Int = 
       
    25   if (n == 1) r else
       
    26    if (n % 2 == 0) Collat(n / 2 , r + 1) else
       
    27      Collat (3 * n + 1 , r + 1)
       
    28 
       
    29 (1 to 10).map(collatz(_))