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 int factorial​(int n)  
    static int product​(ImmutableList<java.lang.Integer> xs)
    For example, if xs is [12, 3, 1760] then 63360 should be returned.
    static int sum​(ImmutableList<java.lang.Integer> xs)
    For example, if xs is [1776, 80, 7] then 1863 should be returned.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • sum

      public static int sum​(ImmutableList<java.lang.Integer> xs)
      For example, if xs is [1776, 80, 7] then 1863 should be returned.
      Parameters:
      xs - the list
      Returns:
      the sum of the list
    • product

      public static int product​(ImmutableList<java.lang.Integer> xs)
      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

      public 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].
      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