#!/boot/system/bin/yab //******************* ProgrammVerzeichnis bestimmen ************************************ n=30 print time$ print fib2(n) print time$ sub fib2(n) if(n<2)then return n endif n=fib2(n-2) + fib2(n-1) return n end sub
print "-----------------" n=30 print time$ print fibonacci (n) print time$ sub fibonacci (n) n1 = 0 n2 = 1 for k = 1 to abs(n) sum = n1 + n2 n1 = n2 n2 = sum next k if n < 0 then return n1 * ((-1) ^ ((-n) + 1)) else return n1 end if end sub
|