sub Fib($) { my $index = shift; my $acc = 0; my $tmp = 1; while( $index-- ) { # Swap the accumulator and the temp. # Use an Xor swap for fun and to amaze your friends. $acc^=$tmp^=$acc^=$tmp; # Add the two together and store it in the acc. $acc += $tmp; } return $acc; }