Skip to content

Instantly share code, notes, and snippets.

@Yasushi Yasushi/gist:921438
Created Apr 15, 2011

Embed
What would you like to do?
class Loop2(var n0: Int = 0) {
def calc(n: Int): Int = {
val n1 = n0 + (1 - 2 * (n % 2))
n0 = n
n1
}
}
object Loop2 {
def main(args: Array[String]) {
val l = new Loop2
var n = 1
var i = 0
val t1 = System.currentTimeMillis
while(i < Integer.MAX_VALUE) {
n = l.calc(n)
i+=1
}
val t2 = System.currentTimeMillis
println(n + "\nScala\t" + (t2 - t1)/1000.0)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.