# Prime Numbers

## Recommended Posts

Well i have a math project n Prime Numbers and i was thinking ok making a program to calculate prime numbers.

(who ever heard of a math project)

the above forum and some other help i came up with the prime finder.

you enter a number and it tells you if it is prime.

I would like to make it list the factors (if possible) maby due to some large numbers it would have to be only up to 25 or so factors.

another possible program i would like to make would go through the numbers 1-10000 (maby more but doubt it) and list all the prime numbers it came across.

I dont know how to start my second idea. HELP PLZ!!! I might be able to use the same function but im not sure.

(if there is already a forum which could help me it would be appreated.)

also if you see a flaw or a way to make the "Prime Finder" better plz tell me

thanks

"Its not about the 30 inch 1080p display, or the SLI 8800 ultras, or the DDR3 memory. It's about when you turn on your PC, does it return the favor?"Math is like sex. Sure, it may give some practical results, but that is not why we do it

##### Share on other sites

You seriously have to use the SEARCH FORM before you post. Or take a Quick look in Scripts and Scraps. You'll find a whole TOPIC with several ways on how to calculate primes etc.

With that out of the way, here's my function that uses the sieve of Eratosthenes. It checks for \$n number of numbers if it is a prime or not, and returns that as a array. Use _ArrayDisplay on the return value and you will definately know what I mean.

```Func Eratosthenes(\$n)
Dim \$a[\$n+1]
For \$i = 0 to 1
\$a[\$i] = 0
Next
For \$i = 2 to \$n
\$a[\$i] = 1
Next
Dim \$p = 2
While \$p^2 < \$n+1
\$j = \$p^2
While \$j < \$n+1
\$a[\$j] = 0
\$j = \$j + \$p
WEnd
Do
\$p += 1
Until \$a[\$p] = 1
WEnd
Return \$a
EndFunc```

Edit: It said 'EndFun' at the end of my script. But the fun's only just starting, so I changed it to EndFunc.

##### Share on other sites

I have to write a PhD thesis on the efficacy of Flintstone vitamins on the aleviation of agita in males over 60. Can you help me or should I also use the search function? I wish forums existed when I was in high school!

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

##### Share on other sites

I seriously hope you are joking

I'm not an encyclopedia, I have no idea what you are talking about.

Edit: After going over your post a few times, I still don't understand it.. Mathematics is my thing, biology isn't.

##### Share on other sites

Mandar

i did search the forums and i found you post like that under the link i specified above.

i downlaoded it and saved it and it ran and it jut kept putting a zero and 1 beside the numbers that scrolled really fast. (i waited till about 50000 then quit)

i need a way to record the numbers that are prime and possibly wat there factors are.

i was trying to see if there was any otherways this could be done(not just your way)

i was also looking for advice on my first script.

"Its not about the 30 inch 1080p display, or the SLI 8800 ultras, or the DDR3 memory. It's about when you turn on your PC, does it return the favor?"Math is like sex. Sure, it may give some practical results, but that is not why we do it

##### Share on other sites

You are checking that IsPrime() function for @error, but it does not support it. This one here does which allows you to leave out @error checking but still have a boolean (True/False) effect.

Edited by MHz

##### Share on other sites

Mandar

i did search the forums and i found you post like that under the link i specified above.

i downlaoded it and saved it and it ran and it jut kept putting a zero and 1 beside the numbers that scrolled really fast. (i waited till about 50000 then quit)

i need a way to record the numbers that are prime and possibly wat there factors are.

i was trying to see if there was any otherways this could be done(not just your way)

i was also looking for advice on my first script.

If \$a[\$n] = 1 Then

;\$n is a prime number

EndIf

List it. It's a school project, You have to do something..

##### Share on other sites

ok

watever

wondering if i could do something like this in autoit

that would be perfect but ill need some help

"Its not about the 30 inch 1080p display, or the SLI 8800 ultras, or the DDR3 memory. It's about when you turn on your PC, does it return the favor?"Math is like sex. Sure, it may give some practical results, but that is not why we do it

##### Share on other sites

If the help I am giving you is worth a 'watever' while it's very good and structured! Go play in traffic! Seriously. Do it yourself.

Edit: Replaced 'Go kill yourself'.

##### Share on other sites

lol

i just had something different in mind

can u live with that??

"Its not about the 30 inch 1080p display, or the SLI 8800 ultras, or the DDR3 memory. It's about when you turn on your PC, does it return the favor?"Math is like sex. Sure, it may give some practical results, but that is not why we do it

##### Share on other sites

Yes. I still think you should do the rest of the work, because it's school.

##### Share on other sites

im being resourseful

give me that

"Its not about the 30 inch 1080p display, or the SLI 8800 ultras, or the DDR3 memory. It's about when you turn on your PC, does it return the favor?"Math is like sex. Sure, it may give some practical results, but that is not why we do it

##### Share on other sites

im being resourseful

give me that

First of all, if your making a program to do your homework that sounds just a tad like cheating. And second, cheating through being "resourseful" is the same as cheating.

##### Share on other sites

Dethredic,

When is your school project due?

taurus905

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

##### Share on other sites

well not soon

the teacher hasent come up with the guidelines for the project.

we can prettymuch do watever(im doing a website)

so not for at least a couple weeks

"Its not about the 30 inch 1080p display, or the SLI 8800 ultras, or the DDR3 memory. It's about when you turn on your PC, does it return the favor?"Math is like sex. Sure, it may give some practical results, but that is not why we do it

##### Share on other sites

well not soon

the teacher hasent come up with the guidelines for the project.

we can prettymuch do watever(im doing a website)

so not for at least a couple weeks

Dethredic,

I don't think that making a program is like cheating, as Piano_Man suggested. But I do think that it's important for you to know the concepts of prime numbers and how and why your program finds them in the most efficient way possible.

When you first started this thread, I wrote an AutoIt script that finds the first 10,000 prime numbers and writes them to a text file in less than one minute. It only took a little searching in this forum to get started and a little more searching on the internet to make it much faster.

I wouldn't be doing you a favor by posting this script right now. And you would be doing yourself an injustice by just copying someone elses code, especially if you couldn't follow what it was doing or why.

If you want to get a good grade for this project, and learn something in the process, this is what I suggest you do:

First, document everything that you do so you can turn it in with your project. This will help show your teacher that you thought things through and learned during its development. That alone is worth a grade. Teachers want to see how you came to get your answer; not just the answer. This is why students get partial credit, even if their answer is wrong.

Second, state your objective and list everything you want your program to do.

Third, break it down into small pieces and complete each task. This will help in troubleshooting.

And last, put it all together.

I am sure that I have overlooked some things and you will find that many people in this forum will be more than happy to help you, if you show that you are trying to help yourself. So, when you get to the third step listed above, post some of your code and explain what that part is trying to do.

Hopefully, someone will help you by giving you more ideas that point you in the right direction, and not just showoff by writing it for you.

A math project may seem silly to you. But you have a chance to develop how to do a project correctly now, that will help you get better grades easier in collage and understand things more quickly when you land that good job.

taurus905

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

## Create an account

Register a new account

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...