changeset 198 | 2ce98ee39990 |
parent 197 | 9c968d0de9a0 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Attic/scala/random.scala Sat Oct 04 13:17:18 2014 +0100 @@ -0,0 +1,18 @@ + +val m = 16 +val a = 5 +val c = 1 +val X0 = 10 + +def ran(n: Int, X: Int) : Set[Int] = n match { + case 0 => Set() + case n => { + val X_new = (a * X + c) % m + Set(X) ++ ran(n - 1, X_new) + } +} + +for (i <- 0 to 16) { + val l = ran(16, i) + println(l.size.toString + " " + l.toString) +}