prime numbers[Resolved by manavo11]
I was trying to create a program that printed all the prime numbers within a given limit. My program is printing out all of the numbers! See if you can figure out where I'm going wrong:
Code:
import java.io.*;
class PrimeCheck
{
public static void main(String[] args) throws Exception
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Limit --> ");
int limit = Integer.parseInt(br.readLine());
System.out.println("");
System.out.print("Primes --> ");
int count = 0;
for (int i=2; i<=limit; i++)
{
for (int j=1; j<=i; j++)
{
if (j * i == i)
{
count++;
}
if (i * j == i)
{
count++;
}
if (count == 2)
{
System.out.print(i + " ");
}
count = 0;
}
}
}
}
Re: prime numbers[Resolved by manova]
I both added the green check mark and changed the name for you....;)
Re: prime numbers[Resolved by manova]
Quote:
Originally Posted by NoteMe
I both added the green check mark and changed the name for you....;)
\
No I did it before you.
Re: prime numbers[Resolved by manavo]
You added [Resolved] Then I added the green check mark. Then I changed the name to Manavo. Was it you that changed it back to manova? Well I have changed it back to Manavo now at least...:)
Re: prime numbers[Resolved by manova12]
You're killing me. manova12? :cry: I'll change it myself :afrog:
Re: prime numbers[Resolved by manova12]
Quote:
Originally Posted by manavo11
You're killing me. manova12? :cry: I'll change it myself :afrog:
Noteme is such a bad person.