0

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);
}


}
3
Contributors
3
Replies
13
Views
4 Years
Discussion Span
Last Post by stultuske
0

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

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.