Thread: How to Determine prime number and making shape using loop?

1. Member
Join Date
Feb 2010
Posts
6
Rep Power
0

How to Determine prime number and making shape using loop?

Hi!:D
I hav 2 question:

1.How to determine all the prime numbers from 0 until the positive integer given by user?

2. How to display this shape using java?

*
***
*****
*******
*********
***
***
*********
..:cool::confused:

2. I hav 2 question:

1.How to determine all the prime numbers from 0 until the positive integer given by user?

2. How to display this shape using java?

*
***
*****
*******
*********
***
***
*********
and...

3. How to ask a question here that shows you've put even a minimal amount of effort towards first trying to answer it yourself.

Please understand that no one is going to do your homework for you, but we'll more than gladly try to help you with your work, providing of course that you first show us this work.

Much luck!
Last edited by Fubarable; 02-20-2010 at 06:51 AM.

3. Member
Join Date
Feb 2010
Posts
6
Rep Power
0
Sorry, I'm not asking people to do my homework-i'm currently doing it.

4. Senior Member
Join Date
Nov 2009
Posts
235
Rep Power
8
then if you are having trouble with a specific part, feel free to ask for help.

5. Member
Join Date
Feb 2010
Posts
6
Rep Power
0
ok...thanx..i don't realize dat it's wrong just to put the question only..

6. Senior Member
Join Date
Nov 2009
Posts
235
Rep Power
8
It's not wrong to only put a question, but people here want to help you learn java, not do homework for you. we usually feel that by answering broad questions like "how to make a program that does ..." is doing homework for the asker, and does not teach them anything. We are more inclined to answer questions that have to do with specific problems in your java program like, "I'm getting an error that says '...', here is my code, what am I doing wrong."

7. Member
Join Date
Feb 2010
Posts
6
Rep Power
0
i see...sorry again if i made people to misunderstand the post.honestly no intention to ask people doing myhomework- :(

8. Originally Posted by collin389
It's not wrong to only put a question,...
For this type of question, the classic "homework dump", I think that it is wrong since the poster isn't really asking a question at all but rather posting a restatement of the entire homework task itself without showing a bit of work.

...but people here want to help you learn java, not do homework for you. we usually feel that by answering broad questions like "how to make a program that does ..." is doing homework for the asker, and does not teach them anything. We are more inclined to answer questions that have to do with specific problems in your java program like, "I'm getting an error that says '...', here is my code, what am I doing wrong."
This I fully agree with.

9. Originally Posted by cyzash
i see...sorry again if i made people to misunderstand the post.honestly no intention to ask people doing myhomework- :(
No problem as you're learning both programming and forum etiquette at the same time. Both will get much better with time, I'm sure.

10. Member
Join Date
Feb 2010
Posts
6
Rep Power
0
//hi this my code for checking n printing prime num
//but still can't run
//anybody know why?
Java Code:
```public void checkNum(int inpNum){
int isPrime=inpNum;
int counter=0;
for(int z=0;z<=isPrime;z++){
for(int y=1;y<=isPrime;y++){
if(z%y==0) {
counter=counter+1;
prime[j]=z;
j++;
}

}if (counter==2) System.out.println(prime[j] +" ");}

}```
Last edited by cyzash; 02-20-2010 at 09:04 AM. Reason: to apply code tag

11. Senior Member
Join Date
Nov 2009
Posts
235
Rep Power
8
Well, you never initialize j
Also, your brute force method is OK I guess but there are much better ways like. Read this: Primality test - Wikipedia, the free encyclopedia
It explains that you only need to check from m to sqrt(n) not n-1, also things like skipping the evens and things like that.