Jump to content
Sign in to follow this  

Recommended Posts

I have written this script to search for solutions to the equasion A^3 + B^3 = C^3; Where A, B and C are positive, whole integers. However, I am not very experianced at using arrays, and i am having some problems:

:nuke:  :nuke:  :nuke: 
Func calculate()
    $SUCCESS_RATE = 0
    $A = 0
    $B = 0
    $C = 0
    $QUITA = 0
    $QUITB = 0
    $AVALUES = 0
    $BVALUES = 0
    While $SUCCESS_RATE = 0
        $C = $C + 1
        $CCUBED = $C ^ 3
        While $QUITA = 0
            Dim $ACUBED[$CCUBED - 1]
            While $AVALUES < $CCUBED
                $AVALUES = $AVALUES + 1
                $ACUBED[$AVALUES] = $AVALUES ^ 3
            WEnd
        WEnd
        While $QUITB = 0
            Dim $BCUBED[$CCUBED - 1]
            While $BVALUES < $CCUBED
                $BVALUES = $BVALUES + 1
                $BCUBED[$BVALUES] = $BVALUES ^ 3
            WEnd
        WEnd
        If $ACUBED + $BCUBED = $CCUBED Then
            $SUCCESS_RATE = 1
        EndIf
    WEnd
    GUICtrlSetData($EDIT_1, "- Success!" + @CRLF + "A=" + $ACUBED^ (1 / 3) + @CRLF + "B=" + $BCUBED^ (1 / 3) + @CRLF + "C=" + $CCUBED^ (1 / 3))
EndFunc  ;==>calculate

:):P;)

Can anybody help? :D:x:(:)::(;)

Share this post


Link to post
Share on other sites

Hello,

1) for the error, $CCUBED-1=0 for the 1st time, so you are declaring an array with 0 as dimension and autoit doesn't like ...

so you can fixe it with this :

While $QUITA = 0
     If $C<>1 Then
         Dim $ACUBED[$CCUBED-1]
         While $AVALUES < $CCUBED
    $AVALUES = $AVALUES + 1
    $ACUBED[$AVALUES] = $AVALUES ^ 3
    WEnd
      EndIf
WEnd

2) You'll never exit from this loop because $QUITA will never change in this loop

3) x^n+y^n=z^n has no positive integer solution (x,y,z) with n>2 (Ferma's theorem)


Share this post


Link to post
Share on other sites

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...