File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic

prime numbers

Brandi Love
Ranch Hand

Joined: Sep 19, 2003
Posts: 133
I need to write a program that finds the prime numbers between 1 and 50, but I'm not quite sure how to do it. I know that an even number is prime if it is two, and an odd is prime if it isn't divisible by any of the odd integers less than the square root of the number. Should I be using a for loop? How should I start it off?
grr frr

Joined: Nov 03, 2003
Posts: 1
I'm sorry my English is very bad, but here is a possible solution :
package Uebungen.Methoden;
import ntb.*;
public class U2{

// code removed by Marilyn
I hope i can help you with this...
[ November 03, 2003: Message edited by: Marilyn de Queiroz ]
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 986

There is someone else here doing the exact same homework assignment. I would suggest you find that thread and check out what people have alreay said on this subject.

Please ignore post, I have no idea what I am talking about.
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 986

I'm confused. You posted all this code and now you are not posting any code and are asking the question like you haven't done anywork, yet, on the problem.
The best way of getting good answers around here is to post some code and poeple can help you out with it.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

I'm confused too. I think I am going to ask that this thread be removed for 2 reasons. You have already asked this question and recieved some answers. Second, grr frr, while trying to help, has violated one of Javaranch's prime directives. And that is not just handing the answers over to people trying to get their homework completed.

GenRocket - Experts at Building Test Data
I agree. Here's the link:
subject: prime numbers
It's not a secret anymore!