Opened 11 years ago
Closed 11 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)
Changed 11 years ago by jennico
comment:1 Changed 11 years ago by TicketCleanup
- Milestone Future Release deleted
- Version 3.2.12.0 deleted
Automatic ticket cleanup.
comment:2 Changed 11 years ago by jennico
bump
i can guarantee you, you will not find a faster algorithm than my _IsPrime uses. it's very clever.
i bet !
j
comment:3 Changed 11 years ago by Valik
This is not a forum. You do not need to bump your ticket.
comment:4 Changed 11 years ago by anonymous
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 Changed 11 years ago by anonymous
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 Changed 11 years ago by Valik
- Resolution set to Rejected
- Status changed from new to closed
These functions don't seem to be useful on a general scale.
Guidelines for posting comments:
- You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
- In-depth discussions should take place on the forum.
For more information see the full version of the ticket guidelines here.
contains _prime.au3 (udf) and _primeexample.au3 (examples)