Jump to content
Sign in to follow this  

Cube Root Add Calculator

Recommended Posts

It's my first script.


- with GUI

- Easily, Put result, get cube roots.

- Category is Math.

- Click to Sart and wait a while.

Example : If you put 91, it will be 3³ + 4³ = 91, so targets are 3 and 4.

; Author : Slaeghtor  Date : 30.05.2011 12.01
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### 
$Form1_1 = GUICreate("Micro Cube Calculator v1.0 - Slaeghtor", 371, 226, 359, 218)
$kup = GUICtrlCreateInput("91", 176, 30, 145, 34, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER))
GUICtrlSetFont(-1, 16, 800, 0, "Calibri")
GUICtrlSetTip(-1, "Put result here.")
$Basla = GUICtrlCreateButton("Start", 24, 88, 147, 57)
GUICtrlSetFont(-1, 24, 800, 0, "Calibri")
$sayi = GUICtrlCreateLabel("         Result :", 24, 30, 133, 33)
GUICtrlSetFont(-1, 18, 800, 0, "Calibri")
$Label1 = GUICtrlCreateLabel("                 Developed by Slaeghtor  slaeghtor@gmail.com", 32, 176, 308, 23)
GUICtrlSetFont(-1, 12, 800, 0, "Calibri")
$Button1 = GUICtrlCreateButton("Help", 202, 87, 147, 57)
GUICtrlSetFont(-1, 24, 800, 0, "Calibri")
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
        Case $Basla
        $sonuc = GUICtrlRead($kup)
        If $sonuc = "" Then
            MsgBox(0, "Error", "You must put a number.")
        ElseIf $sonuc > 2000000000 Then 
            MsgBox(0, "Error", "This number too long for this program.")
        $var1 = Random(1, 1000, 1)
        $var11 = $var1 * $var1
        $var111 = $var1 * $var11
        $var2 = Random(1, 1000, 1)
        $var22 = $var2 * $var2
        $var222 = $var22 * $var2
        Until $var111 + $var222 = $sonuc
        MsgBox(0, "Found", $var1 & "³" & " + " & " " & $var2 & "³" & " = " & $sonuc)
    Case $Button1
        MsgBox(0, "Help", "Put result of cube. It will say you cube root.")

Compiled Link : http://www.mediafire.com/?c70jkf60oww1jo1

Edited by Slaeghtor

Share this post

Link to post
Share on other sites

Good script for your first one.

Now, let's get to business :)

Your script does return some results but ... if the number can't be represented as a sum of the cubes of two integers - your script will be stuck in a loop forever. Just put 8 in the box and wait for your script to finish - I doubt it will be finishing at any time. That being said, your script will fail way too often.

Next: you need to put a check for whatever is entered in yout input box - it needs to accept only numbers - right now it accepts text too and that will make the script hang.

Next: using random numbers to test them is not a fast method at all because you will be testing alot of not needed numbers (if the input is 9 - is there any need to test numbers up to 1000?)

Conclusion: good script but needs alot more work. Good luck.

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post

Link to post
Share on other sites

Thanks for this comment.

I made it for it:

I'm Subscribe to a math magazine. So this magazine asked a question about cube roots. I can't remember now that hwat they asked but:

Example : "What cube roots of 23214522563( < this is example).

So I asked myself that how can I find that and I created this program and shared.

So sorry for this sheet english :)

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...