# Thread: how to resolve last funtion

1. Member
Join Date
Oct 2011
Posts
18
Rep Power
0

## how to resolve last funtion

well I expose th prblem I have a function that resolve the square root of a int on recursive mode , other funtion that says if a matrix is ssymmetric or not in a recursive mode, an the last function must say if the matrix of the square root of the elements is symmetric or not in a recursive mode too, i know i must use the 2 funtion before but always i have the same exception stack overflow i put here the code i have
Java Code:
```package main;

/**
*
*/
public class Main {
public static final int i = 4;
public static final  int j = 4;
public static int x = 0;
public static int y = 0;
public static boolean sym = true;
public static  int m[][] = new int[i][j];
public static int n ;
public static int r;
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
m[0][0]=1;
m[1][0]= 4;
m[2][0]= 3;
m[3][0]= 2;
m[0][1]=4;
m[1][1]=1;
m[2][1]=2;
m[3][1]= 4;
m[0][2]=3;
m[1][2]=2;
m[2][2]=1;
m[3][2]=3;
m[0][3]=2;
m[1][3]=4;
m[2][3]=3;
m[3][3]=1;

SqrtMatSym(m);
System.out.println(SqrtMatSym(m));

}
public static int sqrt(int n) {
//pre >= 0;

if ( (n >= (r*r)) && (n < (r+1)*(r+1)) ){
return(r);
}else {
r++;
sqrt(n);
}return (r);
}

public  boolean matrix(int[][] m) {

if ( i == j){
if (sym== true){
if (x != m.length - 1) {
if (y == m[x].length - 1)
{
if (m[x][y] != m[y][x]) {
sym = false;
}
x++;
y = 0;
matrix(m);
} else {

if (m[x][y] != m[y][x]) {
sym = false;
} else {
y++;
matrix(m);
}
}
}
}
}else{
sym = false;}
return sym;
}
public static boolean SqrtMatSym(int[][] m) {
//need to do teh sqrt of all elements and know if is sym
if ( i == j){
if (sym== true){

if (x != m.length - 1) {
if (y == m[x].length - 1) {

if (m[x][y] != m[y][x]) {
sym = false;
}
x++;
y = 0;
SqrtMatSym(m);
} else {

if (m[x][y] != m[y][x]) {
sym = false;
} else {
y++;
SqrtMatSym(m);
}
}
}
}
}else{
sym = false;}
return sym;
}
}```