Skip to content

Latest commit

 

History

History
137 lines (59 loc) · 1.63 KB

README-IntegerUtils.md

File metadata and controls

137 lines (59 loc) · 1.63 KB

IntegerUtils

  • Ensure each of the test cases in the class IntegerUtilsTest successfully passes upon completion of each of the method stubs in the class IntegerUtils.
    • Integer getSumOfN(int n)
    • Integer getProductOfN(int n)
    • Integer reverseDigits(int val)





Integer getSumOfN(Integer n)

  • Description
    • Given an Integer, n, return the sum of all integers from 0 up to and including n

Example

  • Sample Script

    // : Given
    Integer input = 4;
    
    // : When
    Integer outcome = IntegerUtils.getSumOfN(input);
    
    // : Then
    System.out.println(outcome);
    
  • Sample Output

    10
    





Integer getProductOfN(Integer n)

  • Description
    • Given an Integer , n, return the product of all integers from 0 up to and includingg n.

Example

  • Sample Script

    // : Given
    Integer input = 7;
    
    // : When
    Integer outcome = IntegerUtils.getProductOfN(input);
    
    // : Then
    System.out.println(outcome);
    
  • Sample Output

    5040
    





Integer reverseDigits(Integer n)

  • Description
    • Given an Integer, n, return integer an with identical digits in the reverse order

Example

  • Sample Script

    // : Given
    Integer input = 12345
    
    // : When
    Integer outcome = IntegerUtils.reverseDigits(input);
    
    // : Then
    System.out.println(outcome);
    
  • Sample Output

    54321