Attic/scala/random.scala
changeset 198 2ce98ee39990
parent 197 9c968d0de9a0
equal deleted inserted replaced
197:9c968d0de9a0 198:2ce98ee39990
       
     1 
       
     2 val m = 16
       
     3 val a = 5
       
     4 val c = 1
       
     5 val X0 = 10
       
     6 
       
     7 def ran(n: Int, X: Int) : Set[Int] = n match {
       
     8   case 0 => Set()
       
     9   case n => {
       
    10     val X_new = (a * X + c) % m
       
    11     Set(X) ++ ran(n - 1, X_new) 
       
    12   }
       
    13 }
       
    14 
       
    15 for (i <- 0 to 16) {
       
    16   val l = ran(16, i)
       
    17   println(l.size.toString + " " + l.toString)
       
    18 }