/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package primenumber;
/**
*
* @author mcmanuel
*/
public class PrimeNumber {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int num, a, b, c;
num = 10;
for(a = 1; a <= num; a++)
{
b = 0;
for(c = 2; c <= a/2; c++)
{
if(a%c == 0)
{
b = b + 1;
}
if(c == 0)
{
System.out.println("The prime number is" + a);
}
}
}
}
}
mcmanuel20
0
Newbie Poster
Recommended Answers
Jump to PostWhat's the question?
Jump to PostNo doing any homework for others. Explain to the OP where is wrong and why. Also, your code is extremely slow with bad algorithm even though it is taken directly from the OP. One more, encouraging beginners to ignore the meaning of variable name is ruining others. If these beginners …
All 5 Replies
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
mcmanuel20
0
Newbie Poster
jalpesh_007
-3
Newbie Poster
mLearning
0
Newbie Poster
Taywin
312
Posting Virtuoso
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.