Statistics

Problem Statement for "InequalityChecker"

Problem Statement

Using mathematical induction it is possible to prove the following inequality when n>1:
	s = 13 + 23 + ... + (n-1)3 < n4/4 < 13 + 23 + ... + n3 = S
Given n return (S+s)/2 - n4/4 as a int[] with 2 elements. Elements 0 and 1 denote the numerator and denominator of the return value, respectively, when written in least terms (reduced).

Definition

Class:
InequalityChecker
Method:
getDifferences
Parameters:
int
Returns:
int[]
Method signature:
int[] getDifferences(int n)
(be sure your method is public)

Constraints

  • n will be between 2 and 100 inclusive.

Examples

  1. 2

    Returns: { 1, 1 }

    We have s = 1^3 = 1 S = 1^3 + 2^3 = 9 (S+s)/2 = (1+9)/2 = 5 n^4/4 = 16/4 = 4 Since 5-4 = 1, we return the fraction 1/1.

  2. 3

    Returns: { 9, 4 }

    We have s = 1^3 + 2^3 = 9 S = 1^3 + 2^3 + 3^3 = 36 (S+s)/2 = 45/2 n^4/4 = 81/4 We return the fraction 9/4.

  3. 100

    Returns: { 2500, 1 }

    Largest case.

  4. 4

    Returns: { 4, 1 }

  5. 5

    Returns: { 25, 4 }

  6. 6

    Returns: { 9, 1 }

  7. 7

    Returns: { 49, 4 }

  8. 8

    Returns: { 16, 1 }

  9. 9

    Returns: { 81, 4 }

  10. 10

    Returns: { 25, 1 }

  11. 50

    Returns: { 625, 1 }

  12. 33

    Returns: { 1089, 4 }

  13. 79

    Returns: { 6241, 4 }

  14. 25

    Returns: { 625, 4 }

  15. 97

    Returns: { 9409, 4 }

  16. 98

    Returns: { 2401, 1 }

  17. 99

    Returns: { 9801, 4 }

  18. 91

    Returns: { 8281, 4 }

  19. 92

    Returns: { 2116, 1 }

  20. 93

    Returns: { 8649, 4 }

  21. 94

    Returns: { 2209, 1 }

  22. 95

    Returns: { 9025, 4 }

  23. 96

    Returns: { 2304, 1 }


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: