public class Jacobi{

// jacobi(a,n)
public static void main(String[] args) {
int n = 234567,a = 97770;

if(n<=0 || (n %2) == 0) 
return (0);

int temp, j=1;

if(a<0) {
    a = -a;
    if((n % 4) == 3) 
    j = -j;
           }
do while (a!=0) {
    do while(( a % 2)==0) {
 /* Process factors of 2: Jacobi(2,b)=-1 if b=3,5 (mod 8) */
            a=a/2;
    if((n % 8)==3 || (n % 8) == 5) { 
    j = -j;  }

    }
 /* Quadratic reciprocity: Jacobi(a,b)=-Jacobi(b,a) if a=3,b=3 (mod 4) */

    temp = a;
    a = n;
    n = temp;

    if((a % 4) == 3 && (n % 4) == 3){ 
    j = -j;
    }

    a = a % n; 
}

// here my code is showing,[ line just below, the one start with if(n==1) ],the illegal start of expression,

    if(n == 1) { 


    return(j); 
}

else return(0);
}


}

Recommended Answers

All 3 Replies

you have return statements in a method with returntype void, which means it doesn't return anything.

I agree with stultuske, how can you ask for a return function when you have declared something void, thry the following code

wierd answer, edensigauke:
function isn't really Java terminology, but besides that... when someone says "try the following code", usually, there is 'following code' to try.

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.