Tuesday, January 24, 2012

Fibonacci

/**
 * Fibonacci series:
 * the sum of two elements defines the next
 */

int LIMIT = 1000

(a,b) = [0,1]
while (b < LIMIT) {
    print "$b "
    (a,b) = [b, a+b]
}

(source)

No comments:

Post a Comment