Rectangle Counting on an N x N Chessboard

Given a positive integer N, determine the number of possible rectangles that can be formed on an N x N chessboard, excluding squares.

Input:

The first line contains an integer T, the number of test cases. 
Each of the following T lines contains a single integer N, the dimension of the chessboard.

Output:

For each test case, output the number of rectangles (excluding squares) that can be formed on the chessboard.

Example:

Input:
2
3
4
Output:
20
70

Constraints:

  • 1 <= T <= 10
  • 1 <= N <= 5 * 10^4
  • Results should be returned modulo 1000000007.

Note:

Calculate the total number of rectangles possible and subtract the number of squares from it. Return the count modulo 1000000007 for each test case.
Be the first one to answer
Add answer anonymously...
JPMorgan Chase & Co. Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter