Jump to content

Recommended Posts

Posted

I Slapped Together a little script here to calculate the Fibonacci numbers It go's up to 7540113804746346429 (the 92nd number)until going negative. I'm not asking how to make it go infinitely just seeing if anyone has any comments, concerns or idea's on how to :( JAZZ I UP :)

(Keep in mind I'm relatively new to Autoit)

Global $A
Global $B
Global $C
Hotkeyset("{ESC}", "Off")
Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
$A = 1
$B = 1
$C = $A + $B
Send("" & $A)
Send("{enter}" & $B)
Send("{enter}" & $C)
While 1
    $A = $B
    $B = $C
    $C = $A + $B
    Send("{enter}" & $C)
Wend 

Func Off()
    Exit
EndFunc
Posted (edited)

Hi,

with  bignum.au3it is possible to calculate greater Fibonacci-numbers.

#include <bignum.au3>

Global $A
Global $B
Global $C
Hotkeyset("{ESC}", "Off")
Run("notepad.exe")
WinWaitActive("Unbenannt - Editor")
$A = "1"
$B = "1"
$C = _bignum_add($A,$B)
Send("" & $A)
Send("{enter}" & $B)
Send("{enter}" & $C)
While 1
    $A = $B
    $B = $C
    $C = _bignum_add($A,$B)
    Send("{enter}" & $C)
Wend

Func Off()
    Exit
EndFunc

*EDIT*

but as you can see, "Send" is really slow. If you write the numbers to the console, the script will performed a bit faster

#include <bignum.au3>

Global $A
Global $B
Global $C
Hotkeyset("{ESC}", "Off")

$A = "1"
$B = "1"
$C = "2"

$i=3
While $i<1000  ;Fibonacci-Numbers up to ....
    $i+=1
    $A = $B
    $B = $C
    $C = _bignum_add($A,$B)
    consolewrite( $i&"   "& $C&@crlf)  
Wend

Func Off()
    Exit
EndFunc
Edited by AndyG
Posted

If you find and use the UDF BigNumbers.au3 from here, you can extend the number of accurate Fibonacci numbers returned to well beyond 92.

I changed your seeding numbers from 1 and 1 to Zero and 1.

#include "Full Path Here\BigNumbers.au3"
; BigNumbers.au3 UDF from :-
; http://www.autoitscript.com/forum/index.php?showtopic=83529&view=findpost&p=597491

HotKeySet("{ESC}", "Off")
Local $A, $B, $C, $iCount = 2

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")

$A = 0
$B = 1
$C = $A + $B
Send("0" & @TAB & $A) ; 1st seed
Send("{enter}" & "1" & @TAB & $<img src='http://www.autoitscript.com/forum/public/style_emoticons/<#EMO_DIR#>/cool.png' class='bbc_emoticon' alt='B)' /> ; 2nd seed and 1st Fibonacci number
Send("{enter}" & "2" & @TAB & $C) ; 2nd Fibonacci number Fn = F(n-1) + F(n-2)

While 1
    $iCount += 1
    $A = $B
    $B = $C
    $C = _BigNum_Add($A, $<img src='http://www.autoitscript.com/forum/public/style_emoticons/<#EMO_DIR#>/cool.png' class='bbc_emoticon' alt='B)' />
    Send("{enter}" & $iCount & @TAB & $C)
WEnd

Func Off()
    Exit
EndFunc ;==>Off

#cs
Extra correct Fibonacci numbers returned :-

    91  4660046610375530309
    92  7540113804746346429
    93  12200160415121876738
    94  19740274219868223167
    95  31940434634990099905
    96  51680708854858323072
    97  83621143489848422977
    98  135301852344706746049
    99  218922995834555169026
    100 354224848179261915075
    101 573147844013817084101
#ce

Yesterday or the day before, I came across a Fibonacci string, which I did not realize existed.

It is based on :-

Fibonacci String, fn = f(n-1) & f(n-2) ; For n >= 3, and two string seeds.

In the following example, the two string seeds used are "b" and "a".

#include <Array.au3>

Local $FibonacciString[11] = [0]
$FibonacciString[1] = "b"
$FibonacciString[2] = "a"

;Fibonacci String, fn = f(n-1) & f(n-2) ; For n >= 3.
For $i = 3 To UBound($FibonacciString) - 1
    $FibonacciString[$i] = $FibonacciString[$i - 1] & $FibonacciString[$i - 2]
Next

_ArrayDisplay($FibonacciString)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...