why can not resolve symbol?

Hi guys

I want to print out the prime numbers between 0 to 25

but the complier says can not resolve the symbolvariable m

can you help me?

my code:-

class algorithm{

staticboolean check;

publicstaticvoid prime(int m,int n){

check=true;

n =25;

for(int i=2;i<n;i++)

for(m=3;m ><n;m++)

if(m/i==0)

{

check=false;

break;

}

if(check)

{

System.out.print(+m);

}

}

publicstaticvoid main(String [] args){

System.out.print(" "+m);

}}

Message was edited by:

vanpersie

Message was edited by:

vanpersie>

[1661 byte] By [vanpersiea] at [2007-11-27 7:37:56]
# 1
Hi there,Well you have a method called prime which you are not calling from anywere and also you must declare m.int m = 0; // for exampleHope this helps
Xenobiusa at 2007-7-12 19:18:34 > top of Java-index,Java Essentials,New To Java...
# 2

The variable m is in the scope of function prime(...) not in the scope of main(...) ry the following code:

class algorithm {

int m;

static boolean check;

public static void prime(int m1, int n){

m=m1;

check=true;

n =25;

for(int i=2;i<n;i++)

for(m=3;m ><n;m++)

if(m/i==0)

{

check=false;

break;

}

if(check)

{

System.out.print(+m);

}

}

public static void main(String [] args){

System.out.print(" "+m);

}}

>

diptaPBa at 2007-7-12 19:18:34 > top of Java-index,Java Essentials,New To Java...
# 3

public class PrimeTest {

public static boolean isPrime ( int num )

{

boolean prime = true;

int limit = (int) Math.sqrt ( num );

for ( int i = 2; i <= limit; i++ )

{

if ( num % i == 0 )

{

prime = false;

break;

}

}

return prime;

}

public static void main(String [] args){

for(int i=1;i<50;i++)

{

boolean b = isPrime(i);

if(b)

System.out.print(i+" ; ");

}

}

}

Hope this works....

LetMeSeea at 2007-7-12 19:18:34 > top of Java-index,Java Essentials,New To Java...
# 4
YES IT WORKS THANK YOU VERY MUCH
vanpersiea at 2007-7-12 19:18:34 > top of Java-index,Java Essentials,New To Java...