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

kglad
Community Expert
Community Expert
May 15, 2007
0x means a hexadecimal number follows. if you want to see the decimal representation of a hex number (like var1), just use:

trace(var1);

p.s. this is the 23k post. and thanks!
Known Participant
May 15, 2007
by the time you read this it will already be time to say....

HAPPY 23K post, man... that is ALOT of posts!
Known Participant
May 15, 2007
how would i make those positive numbers, it shows me negative ones... if i wanted them to be 0, or above that, what would i do... i understand how hex and decimal works but i have no idea what the 0x... means.
kglad
Community Expert
Community Expert
May 15, 2007
that converts the number 0xFFB0 to a 32 bit integer and then shifts the bits 2 places to the right.

the easiest way to understand that is to use something like:

var1 = 0xFFB0;
trace(var1.toString(16));
var2 = 0xFFB0 >> 2; // try using an 8 instead of a 2 to see something more understandable
trace(var2.toString(16));
Known Participant
May 15, 2007
hey what does this mean?

{(0xFFB0 >> 2) in decimal format}
kglad
Community Expert
Community Expert
May 15, 2007
you're welcome. and good luck!
Known Participant
May 15, 2007
well i think your right which is why i had to ask...

1 - my project does not need to be in as3 and i am exceptionally proficient with as2. i just wanted to learn as3, it was not required... i would rather just create a personal project in order to fulfill my wants for learning the new version.

2 - i do not plan to finish this asap... i would like to but i do not think that is a realistic expectation i can fulfill.

3 - i agree and... super! i think i will hit that as2 up.

thanks for the help and i will keep this forum alive for the rest of the time adobe is around haha. ill give you some updates.. thank you for the help... stay in touch orrr stay on this forum!
kglad
Community Expert
Community Expert
May 15, 2007
it depends upon your goals.

first, if your project absolutely needs some feature of a.s 3, you have to stay with a.s. 3. 2nd, if you're not that proficient with a.s. 2, you may as well stay with a.s. 3 and not look back at a.s. 2. it is a dead language that will disappear over the next 5 to 10 years.

next, if you need to get this finished asap and you're much more proficient in a.s. 2 than a.s. 3 and you don't need anything in a.s. 3 for your project, you're probably better off going to a.s. 2.

and finally, if time is not critical and you want to learn a.s. 3, having a project to complete is a good way to learn.
Known Participant
May 15, 2007
never mind kglad, it is something else and man i am thinking it would just be easier if i had linked classes that called whatever was needed as needed and convert this all to as2.0... the thing is i have been recoding and reconstructing the entire thing over and over again and man i am beyond completely vexed... i really really really like the way as3 provides much better support for loading variables...

i guess my final question (for now!!) would be what do you think... should i just invest the time and convert this as2.0 or continue in as3.0 and rebuild this peice by piece and try to figure out what the problem is.
Known Participant
May 15, 2007
never mind kglad, it is something else and man i am thinking it would just be easier if i had linked classes that called whatever was needed as needed and convert this all to as2.0... the thing is i have been recoding and restructing the entire thing over and over again and man i am beyond completely vexed... i really really really like the way as3 provides much better support for loading variables...

i guess my final question (for now!!) would be what do you think... should i just invest the time and convert this as2.0 or continue in as3.0 and rebuild this peice by piece and try to figure out what the problem is.