• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Prime Numbers

 
Koh Khai Huat
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys if any one knows how to create a program with java to calculate Prime numbers???
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Niyas Ahmed Sheikh
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
May be helpful....web page
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Regards,

Layne
 
Tom Blough
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably more than you wanted to know.

Cheers,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic