Loading Now

diffPow

Let x be the non-negative difference between the square of the sum of the first n natural numbers and the sum of the sixth powers of the first n natural numbers.

Write a function that returns x mod 1000000007.

Example

  • For n = 4, the output should be diffPow(n) = 4790

      (1^6 + 2^6 + 3^6 + 4^6) – (1 + 2 + 3 + 4)^2 = 4790

Input/Output:

  • [execution time limit] 0.5s in C++, 3s in C# and Java, 4s in Python and Java Script.

  • [input] integer n

    1 <= n <= 40

  • [output] integer

Difference between the square of the sum of the first n natural numbers and the sum of the sixth powers of the first n natural numbers Mod 1000000007.

Post Comment

Contact