-accumulate in iterative and recursive method