Statistics

Problem Statement for "PowSum"

Problem Statement

Given an int low, an int high, and an int pow, return the sum of i^j, for all i between low and high, inclusive, and all j between 1 and pow, inclusive.

Definition

Class:
PowSum
Method:
getSum
Parameters:
int, int, int
Returns:
int
Method signature:
int getSum(int low, int high, int pow)
(be sure your method is public)

Constraints

  • low will be between -100 and 100, inclusive.
  • high will be between low and 100, inclusive.
  • pow will be between 1 and 10, inclusive.
  • The return value will fit in a signed 32 bit datatype.

Examples

  1. 1

    3

    2

    Returns: 20

    1^1 + 2^1 + 3^1 + 1^2 + 2^2 + 3^2 = 1 + 2 + 3 + 1 + 4 + 9 = 20

  2. -12

    12

    9

    Returns: 1637738440

    Note that intermediate values may exceed the 32 bit restriction.

  3. -100

    100

    2

    Returns: 676700

  4. -43

    64

    3

    Returns: 3549492

  5. -87

    87

    5

    Returns: 2051859040

  6. -89

    -14

    1

    Returns: -3914

  7. 80

    80

    1

    Returns: 80

  8. -44

    52

    1

    Returns: 388

  9. -30

    30

    5

    Returns: 10566908

  10. -96

    -5

    1

    Returns: -4646

  11. -69

    55

    3

    Returns: -3292625

  12. 50

    67

    4

    Returns: 224535966

  13. -51

    35

    3

    Returns: -1301636

  14. -87

    -6

    1

    Returns: -3813

  15. 25

    94

    2

    Returns: 280560

  16. -65

    78

    4

    Returns: 842322936

  17. 7

    7

    6

    Returns: 137256

  18. 12

    73

    3

    Returns: 7425523

  19. -3

    39

    3

    Returns: 629692

  20. 4

    15

    2

    Returns: 1340

  21. 38

    60

    2

    Returns: 57362

  22. -49

    28

    1

    Returns: -819

  23. -45

    85

    2

    Returns: 242350

  24. -12

    29

    3

    Returns: 192703

  25. -54

    74

    4

    Returns: 560755174

  26. -24

    100

    3

    Returns: 25760500

  27. -12

    8

    7

    Returns: -63422460

  28. 41

    94

    2

    Returns: 262800

  29. 42

    66

    4

    Returns: 239665370

  30. -22

    51

    1

    Returns: 1073

  31. 20

    29

    3

    Returns: 159455

  32. -49

    83

    4

    Returns: 882032858

  33. 95

    100

    2

    Returns: 57640

  34. -90

    36

    1

    Returns: -3429

  35. -18

    -8

    2

    Returns: 1826

  36. -98

    -23

    4

    Returns: 1829964290

  37. 45

    68

    2

    Returns: 79120

  38. 78

    92

    2

    Returns: 109930

  39. -19

    61

    1

    Returns: 1701

  40. 2

    7

    4

    Returns: 5624

  41. 18

    72

    4

    Returns: 407228184

  42. 47

    52

    3

    Returns: 745339

  43. 50

    71

    4

    Returns: 319369600

  44. 63

    87

    2

    Returns: 143800

  45. -78

    76

    2

    Returns: 310310

  46. -35

    41

    3

    Returns: 383383

  47. -62

    34

    2

    Returns: 93702

  48. 44

    45

    1

    Returns: 89

  49. -10

    62

    2

    Returns: 83658

  50. 58

    70

    1

    Returns: 832

  51. -91

    -79

    3

    Returns: -7937033

  52. 47

    49

    3

    Returns: 339122

  53. 28

    33

    2

    Returns: 5782

  54. 8

    37

    1

    Returns: 675

  55. -49

    0

    1

    Returns: -1225

  56. -12

    12

    9

    Returns: 1637738440

  57. -79

    78

    5

    Returns: -1846069551

  58. -11

    10

    9

    Returns: -1821981139

  59. -50

    -45

    2

    Returns: 13270

  60. -10

    -10

    1

    Returns: -10


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: