example java code of implementing recursive functions