The sum of the numbers from 1 to n can be defined recursively as follows: The sum from 1 to 1 is 1. The sum from 1 to n is n more than the sum from 1 to n-1. Write a int -method named sum that accepts an int parameter, n, and recursively calculates and returns the sum of the numbers from 1 to n.

LANGUAGE: JAVA

CHALLENGE:

The sum of the numbers from 1 to n can be defined recursively as follows:
The sum from 1 to 1 is 1.
The sum from 1 to n is n more than the sum from 1 to n-1.
Write a int -method named sum that accepts an int parameter, n, and recursively calculates and returns the sum of the numbers from 1 to n.

SOLUTION:

The Bad News: The content you are trying to access is only available to members.

The Good News: You too can be a member, simply Click Here.

Already a member?

Posted in ,