Opened 17 years ago
Closed 17 years ago
#592 closed Feature Request (Rejected)
a collection of prime based or prime related math functions
| Reported by: | jennico | Owned by: | |
|---|---|---|---|
| Milestone: | Component: | AutoIt | |
| Version: | Severity: | None | |
| Keywords: | _prime.au3 | Cc: | jennico@… |
Description
;#=#INDEX#==============================================================================================================================#
;# Title .........: _Prime.au3 #
;# Description....: A collection of Prime based and Prime related mathematical operations #
;# Date ..........: 22.9.08 #
;# Author ........: jennico (jennicoattminusonlinedotde) #
;# Functions......: _IsPrime ( $s_number, $s_limit = 32000000 ) #
;# _PrimeNext ( $s_number ) #
;# _PrimePrevious ( $s_number ) #
;# _IsEven ( $s_number ) #
;# _Cross ( $s_number, $s_mode=0 ) #
;# _Factorial ( $s_number ) #
;# _gcd ( $s_number1, $s_number2 = "-", $s_number3 = "-", $s_number4 = "-", $s_number5 = "-" ) #
;# _lcm ( $s_number1, $s_number2 = "-", $s_number3 = "-", $s_number4 = "-", $s_number5 = "-" ) #
;# 1000 ( $x, $s_separator = "" ) #
;# Internal...: Euclid ( $a, $b ) #
;# _ggT ( $s_number1, $s_number2 = "", $s_number3 = "", $s_number4 = "", $s_number5 = "" ) #
;# _kgV ( $s_number1, $s_number2 = "", $s_number3 = "", $s_number4 = "", $s_number5 = "" ) #
;#======================================================================================================================================#
other languages have built in functions like _isprime, _primenext, _primeprevious, _gcd, _lcm, _factorial or _cross, which are very useful for scripting
i scripted very fast implementations of _isprime, _gcd (greatest common divisor) and _lcm(least common multiply)
all functions could be added to math.au3 or even build in.
thanks for your attention
j.
Attachments (1)
Change History (7)
by , 17 years ago
| Attachment: | _prime.zip added |
|---|
comment:2 by , 17 years ago
bump
i can guarantee you, you will not find a faster algorithm than my _IsPrime uses. it's very clever.
i bet !
j
comment:4 by , 17 years ago
at least just a single line, like interesting, not working, awesome or bad would be satisfying. we all just attempt to improve AutoIt.
comment:5 by , 17 years ago
Nitpick... don't use the following:
$s_limit = $s_number / $i
You will get the same optimization by simply initializing $s_limit to the square root of $s_number, but without having to perform a division op with every step of the loop. If you do that, then your test will have to be >= instead of >.
And yes, there is a way to do this even faster, though the sqrt optimization is the fastest you can get without getting too complicated.
comment:6 by , 17 years ago
| Resolution: | → Rejected |
|---|---|
| Status: | new → closed |
These functions don't seem to be useful on a general scale.

contains _prime.au3 (udf) and _primeexample.au3 (examples)