Skip to main content
Known Participant
May 1, 2007
Question

Prime Calculator

  • May 1, 2007
  • 47 replies
  • 4835 views
Hello everyone,

for the last week i have been trying to develop a prime number calculator. at first, it was a single input function that determined if it was prime or not. now it takes two numbers (min, max) but it takes to long and is not efficient enough to computer anything large within a certain range. (i.e. 0-15000). how would i make this algorithm significantly more efficient... without using the for loop to compare each number against a modulus check.

////////////////////////////////////////////////////////////////////
code attached with screen print of flash file
////////////////////////////////////////////////////////////////////
download zip version with all files:
rar version: prime number test (flash cs3+as2)
zip version: prime number test (flash cs3+as2)
thank you for any help
isaaac
This topic has been closed for replies.

47 replies

Known Participant
May 11, 2007
haha yeah, i completely agree, i HATE as3, it is the worst thing since micheal jackson. i love as2, it was so perfect and everything flowed together and the syntax was robust.
Inspiring
May 11, 2007
Oh version 3. AS2 is great. The documentation rocks and I've been using it for a very loooonnggg time. AS3 – the documentation is awful, there is no syntax checking, and oh, did I mention the documentation sucks!
Inspiring
May 11, 2007
Oh version 3. AS2 is great. The documentation rocks and I've been using it for a very loooonnggg time. AS3 – the documentation is awful, there is no syntax checking, and oh, did I mention the documentation sucks!
Known Participant
May 11, 2007
HA, i know god i hate those kind of error messages, they give no feedback and its so hard to find out what is wrong, i started deleting different movie instances and it fixes it but then it messes up and i can not find any pattern or relation to make a connection for why this is coming up. you said you are finding as hard to work with... version 2 or 3?
Inspiring
May 11, 2007
Well evidently, "The supplied DisplayObject must be a child of the caller." :) I have no idea. I'm finding AS quite difficult to work with.

I haven't seen kglad posting here, so I don't know. I'm sure he will be around eventually.
Known Participant
May 11, 2007
hey do you know if that guy is back from vacation yet... also, i know your a matrix guru but i have another question about errors in flash... it is error 2025 from an a.s. 3 file and a flash cs3 file.
Inspiring
May 5, 2007
Hi. I'm still here. Just don't know what else I can contribute.

I don't know anything about wheel factorizations, so I don't know what to say.
Known Participant
May 5, 2007
where did everybody go?
Known Participant
May 2, 2007
haha alright
May 2, 2007
Alright, I've converted the pseudo-code into ActionScript. Unfortunately, it is still slower, because of it's inefficient way of findind solutions to the diophantine quadratics.
Known Participant
May 3, 2007
I really like the way you setup your code... especially the way you setup the functions... naming them after the type they are, very user-friendly. Also, I especially like the timing function.

You say the dilemma of efficiency still applies because of the diophantine quadratics problem... well, I was under the impression that the atkin equation was very efficient. You know, I was scouring the internet for additional topics like this one and there are a multitude of solutions to this equations but I am unable to convert those into actionscript. I really hate to sound like a rookie but man that kind of math is perplexing to me. if i wanted to test numbers in the 64-bit range with this equation (the equation being either one), what would you postulate the wait time would be to produce a solution. I tried to do that today but ran out of time. If i sent you links to the equations I found, could you tell me if they would be accurate or not... I hate to ask if you would be willing to convert those into actionscript as well so I will do that if you don't want (you have helped me more than enough).

Finally, I was reading the wheel factorization method and thought about that all day today... my question is this: because of the way that works and the complexity of these equations, could they be simplified by applying pi to them... like below.

//this link is for a picture of two different equations seperated by a light shade of color over
//them. Like i said earlier, i do not understand these but i can postulate what they mean
//and utilize google to help further my understanding (goddd, sometimes i wish i was
//a mathematician!).
// equations picture
//this link is the actual page i found to eqations on and it has an explanation of what they
//mean, how they are applied and so on.
// prime number explanations
//here is another interesting site with a much better breakdown of the information above
//and is a little more simplistic
// this is a lot easier to understand
//this is really interesting and explains the zeta function and how to use it (don't really
//know if it can be applied but it's cool
// the zeta function
//MAYBE THIS IS THE EQUATION WE ACTUALLY NEED TO SOLVE THIS... LET ME
//KNOW IF YOU THINK SO...
// hm function
Inspiring
May 2, 2007
PS: Actually I delete the delete line and the line that traces the primes. Obviously I didn't delete the line that tells me the time!