public static boolean what (Node n)
{
   if (n == null)
	return true;
   if (n.getLeftSon()==null && n.getRightSon()==null)
	return true;
   if (n.getRightSon()==null)
	return (n.getNumber() % n.getLeftSon().getNumber() == 0) 
			&&
        what (n.getLeftSon());
   if (n.getLeftSon()==null)
	return (n.getNumber() % n.getRightSon().getNumber() == 0) 
			&&
        what (n.getRightSon());

   return (n.getNumber() % n.getLeftSon().getNumber() == 0) 
     &&   (n.getNumber() % n.getRightSon().getNumber() == 0)
     &&	what (n.getLeftSon()) 
     &&	what (n.getLeftSon());
}

I think that the method checks for sons which are zeros, in case she find out, she return false, else she returns true? right ?

Returns true if each "father" can be divided by each of their "sons". false even if one of the fathers cannot be divided by theirs sons. If a node is null, it does not check it and returns true.

Returns true if each "father" can be divided by each of their "sons". false even if one of the fathers cannot be divided by theirs sons. If a node is null, it does not check it and returns true.

Then if I'll take the tree (attached file) the returns value will be false ?

Attachments tree.JPG 5.75 KB
This question has already been answered. Start a new discussion instead.