- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to find the 3 Pythagorean triplets with only one number?
Given: Pythagorean triplets
To explain: Here we have to explain how to find Pythagorean triplets with only one number.
Solution:
If the number is odd:
Square the number (n) and then divide it by 2.
Take the integer that is immediately before and after that number
i.e. $\left(\frac{n^{2}}{2} \ -\ 0.5\right)$ and $\left(\frac{n^{2}}{2} \ +\ 0.5\right)$.
Pythagorean triplet = n, $\left(\frac{n^{2}}{2} \ -\ 0.5\right)$ and $\left(\frac{n^{2}}{2} \ +\ 0.5\right)$.
Example:
Take number n = 3.
On squaring the number, we get 9.
Now take half of it: $\frac{9}{2}$ = 4.5
The integer immediately before 4.5 = 4
The integer immediately after 4.5 = 5
Therefore, the triplets are 3, 4 and 5.
If the number is even:
Take the half of that number (n) and then square it.
Pythagorean triplet = n, $\left(\frac{n}{2}\right)^{2} \ -\ 1$ and $\left(\frac{n}{2}\right)^{2} \ +\ 1$
Example:
Take number n = 8
Half of n = 4.
Pythagorean triplet = 8, (42 $-$ 1) and (42 $+$ 1) = 8, 15 and 17.