ezzetabi Posted October 6, 2004 Posted October 6, 2004 (edited) Pretty useless, but fun script for calculate prime numbers until a you limit you want. ;Better code below. Edited October 6, 2004 by ezzetabi
Guest BL@(K-R34P3R Posted October 6, 2004 Posted October 6, 2004 I think that would be useful for my little brother. Let me copy + paste that really quick =)
CyberSlug Posted October 6, 2004 Posted October 6, 2004 Just wondering: Should the line If $primi[$c] > $n / 2 Then ExitLoop beIf $primi[$c] > Sqrt($n) Then ExitLoop Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
ezzetabi Posted October 6, 2004 Author Posted October 6, 2004 Thanks to a CyberSlug idea and a my idea we have a much faster version! expandcollapse popupDim $PRIMI[2], $N = 1, $C, $T = 0, $L, $LIMIT, $PATH $LIMIT = 5000 $PATH = 'c:\primi.txt' If $LIMIT < 2 Then Exit $PRIMI[0] = 1 $PRIMI[1] = 2 $FILE = FileOpen($PATH, 2) If $FILE = -1 Then Exit FileWrite($FILE, '2' & @CRLF);It adds 2 to the file since it is already in the array as begin of all. HotKeySet('!x', '_Terminate') While 1 $N = $N + 2;It skips all divisible by 2 numbers. The 2 is already added as begin. ;since they can't be prime. $T = 0 If $N >= $LIMIT Then Exit For $C = 1 To $PRIMI[0] If $PRIMI[$C] > Sqrt($N) Then ExitLoop;It avoids useless controls If Mod($N, $PRIMI[$C]) = 0 Then $T = 1 ExitLoop EndIf Next If $T = 0 Then $L = UBound($PRIMI) ReDim $PRIMI[$L + 1] $PRIMI[0] = $L $PRIMI[$L] = $N FileWrite($FILE, $PRIMI[$PRIMI[0]] & @CRLF) ToolTip($PRIMI[$PRIMI[0]]) EndIf Wend Exit Func _Terminate() FileClose($FILE) Exit EndFunc ;==>_Terminate
this-is-me Posted October 6, 2004 Posted October 6, 2004 If you really are looking for prime numbers, You can use Prime95 from here: http://www.mersenne.org/freesoft.htmThat is, unless the novelty of this script is not the fact that it finds prime numbers, but that it finds those numbers using autoit. Who else would I be?
ezzetabi Posted October 6, 2004 Author Posted October 6, 2004 I never said I made somthing new. Also for serious password cracking the limit of Autoit variables is too strict. I made this just for fun.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now