~statianzo/sevenlangs

sevenlangs/io/fibonacciLoop.io -rw-r--r-- 260 bytes
2fcd4511Jason Staten day one logic style 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
fibLoop := method(n,
  prev := 1;
  result := 0;
  while(n > 0,
    n = n - 1;
    temp := result
    result = prev + result
    prev = temp
  )

  result
)

fibLoop(30) println

# time of fibLoop(30)
# real    0m0.047s
# user    0m0.041s
# sys     0m0.004s