Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Fibonacci..so slow by Recursion

$
0
0
Recursion ver.
[ autoit ]      
$start = "" MsgBox(0, "",_fibo(40) &@CRLF &"Spend: " &TimerDiff($start) &" Sec") Func _fibo($f) $start = TimerInit() If $f <= 1 Then Return 1 Else Return _fibo($f - 1) + _fibo($f - 2) EndIf EndFunc

Why is it run so slowly.....??
************************************************************
For ver.
[ autoit ]      
$start = "" MsgBox(0, "", _fibloop(40) &@CRLF &"Spend: " &TimerDiff($start) &" Sec") Func _fibloop($s) $start = TimerInit() $a = 1 $b = 1 For $i = 2 To $s $temp = $a $a = $a + $b $b = $temp Next Return $a EndFunc

Be Fast!! ;)

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>