• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Speed of applets vs. compiled scripts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Speed of applets vs. compiled scripts


  • Subject: Re: Speed of applets vs. compiled scripts
  • From: "Geoff Canyon" <email@hidden>
  • Date: Mon, 28 Jan 2002 10:09:16 -0800

At 12:09 PM -0500 1/28/02, email@hidden wrote:
>You only have to try divisors up to sqrt(i), rather than i/2. As i gets large,
>the savings are significant. (Specifically, you get an advantage of sqrt(i)/2.)

The advantage of only calculating to the square root is huge. The changes below are more modest, cutting the time roughly in half.

set t to (current date)
set pList to {2}
repeat with i from 3 to 10001 by 2
set tHowMany to count pList
set tStopVal to sqrt (i)
repeat with j from 1 to tHowMany
set tWhichPrime to item j of pList
if tWhichPrime > tStopVal then
set end of pList to i
exit repeat
end if
if i mod tWhichPrime = 0 then exit repeat
end repeat
end repeat


  • Follow-Ups:
    • Re: Speed of applets vs. compiled scripts
      • From: email@hidden (Michael Sullivan)
References: 
 >Speed of applets vs. compiled scripts (From: email@hidden)

  • Prev by Date: Re: Speed of applets vs. compiled scripts
  • Next by Date: Re: Problems with speed & issues with coercion in OS 9.2.2 (AppleScript 1.7)
  • Previous by thread: Speed of applets vs. compiled scripts
  • Next by thread: Re: Speed of applets vs. compiled scripts
  • Index(es):
    • Date
    • Thread