wood burning stoves
The moose likes Beginning Java and the fly likes Prime Numbers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Prime Numbers" Watch "Prime Numbers" New topic

Prime Numbers

Koh Khai Huat
Ranch Hand

Joined: Aug 05, 2005
Posts: 100
Hi guys if any one knows how to create a program with java to calculate Prime numbers???

if (!WorkHard){
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24193

And again, this JavaRanch forum is for discussing JavaRanch itself. We've got other forums for discussing Java programming and other topics. This one is for beginning Java questions; I'll move this post there for you.

[Jess in Action][AskingGoodQuestions]
Niyas Ahmed Sheikh
Ranch Hand

Joined: Jun 15, 2005
Posts: 129
May be helpful....web page
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Can you be more specific? In particular, do you need to generate prime numbers or do you need to determine if a given number is prime. One simple approach to the former is

(Note this is pseudocode so it will not compile in Java directly.)

This relies on determining that a given number is prime. I'll leave this to you to figure out with some hints:

1) What does it mean for a number to be prime?
2) How can you determine if a number is NOT prime?

If you can come up with answers to these two questions, that would be a good starting place. Feel free to discuss your ideas here and we will be glad to help out.



Java API Documentation
The Java Tutorial
Tom Blough
Ranch Hand

Joined: Jul 31, 2003
Posts: 263
Probably more than you wanted to know.


Tom Blough<br /> <blockquote><font size="1" face="Verdana, Arial">quote:</font><hr>Cum catapultae proscriptae erunt tum soli proscripti catapultas habebunt.<hr></blockquote>
I agree. Here's the link: http://aspose.com/file-tools
subject: Prime Numbers
It's not a secret anymore!