linear sum using recursion in java