We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #9: Special Pythagorean triplet

Project Euler #9: Special Pythagorean triplet

Problem
Submissions
Leaderboard
Discussions

This problem is a programming version of Problem 9 from projecteuler.net

A Pythagorean triplet is a set of three natural numbers, , for which,

For example,

Given , Check if there exists any Pythagorean triplet for which
Find maximum possible value of among all such Pythagorean triplets, If there is no such Pythagorean triplet print .

Input Format

The first line contains an integer i.e. number of test cases.
The next lines will contain an integer .

Constraints

Output Format

Print the value corresponding to each test case in separate lines.

Sample Input 0

2
12
4

Sample Output 0

60
-1

Explanation 0

  • For , we have a triplet , whose product is .
  • For , we don't have any pythagorean triple.

Author

shashank21j

Difficulty

Easy

Max Score

100

Submitted By

17335

Need Help?


View discussions
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits

Choose a translation


  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy