Package immutable.list.apps.assignment
Class SumProductCountdownFactorial
java.lang.Object
immutable.list.apps.assignment.SumProductCountdownFactorial
public class SumProductCountdownFactorial
extends java.lang.Object
- Author:
- __STUDENT_NAME__, Dennis Cosgrove (http://www.cse.wustl.edu/~cosgroved/)
-
Constructor Summary
Constructors Constructor Description SumProductCountdownFactorial() -
Method Summary
Modifier and Type Method Description static ImmutableList<java.lang.Integer>countdown(int n)For example, if n is 5 then the result should be the list [5,4,3,2,1].static intfactorial(int n)static intproduct(ImmutableList<java.lang.Integer> xs)For example, if xs is [12, 3, 1760] then 63360 should be returned.static intsum(ImmutableList<java.lang.Integer> xs)For example, if xs is [1776, 80, 7] then 1863 should be returned.
-
Constructor Details
-
SumProductCountdownFactorial
public SumProductCountdownFactorial()
-
-
Method Details
-
sum
For example, if xs is [1776, 80, 7] then 1863 should be returned.- Parameters:
xs- the list- Returns:
- the sum of the list
-
product
For example, if xs is [12, 3, 1760] then 63360 should be returned.- Parameters:
xs- the list- Returns:
- the result of multiplying the values in xs
-
countdown
For example, if n is 5 then the result should be the list [5,4,3,2,1].- Parameters:
n- the value to countdown from- Returns:
- the list which contains the numbers from n down to 1
-
factorial
public static int factorial(int n)- Parameters:
n- the value- Returns:
- n!
- See Also:
- Factorial on Wikipedia
-