if ( x != 1 && x != 0 ) { z = Calc(x) + 0.5 ; } else { z = x ; } // where: int Calc( int x ) { float z ; float y = float(x*x) ; z = (float) Math.sqrt( y*y + 2.0*y*x + 1.5*y + 0.5*x + 0.0625 ) ; return (int) z ; }