Modify

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)

_prime.zip (5.2 KB ) - added by jennico 17 years ago.
contains _prime.au3 (udf) and _primeexample.au3 (examples)

Download all attachments as: .zip

Change History (7)

by jennico, 17 years ago

Attachment: _prime.zip added

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

comment:1 by TicketCleanup, 17 years ago

Milestone: Future Release
Version: 3.2.12.0

Automatic ticket cleanup.

comment:2 by jennico, 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:3 by Valik, 17 years ago

This is not a forum. You do not need to bump your ticket.

comment:4 by anonymous, 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 anonymous, 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 Valik, 17 years ago

Resolution: Rejected
Status: newclosed

These functions don't seem to be useful on a general scale.

Modify Ticket

Action
as closed The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.