Impact-Site-Verification: dbe48ff9-4514-40fe-8cc0-70131430799e

Search This Blog

#Day11- #100DaysChallenge- Matlab Loops| PythagoreanTriple

#Day11-  Pythagorean Triple

Find the  four different positive numbers, a, b, c and d,  in increasing order: a < b < c < d, and also find if any three of them comprise sides of a right-angled triangle. Return 1 if the condition is ok else 0

Note: This code can be done using the in-built command. But for the challenge, I am trying to avoid those

Pythagorean Triple:

Where 3,4,5 are Pythagorean Triple

Matlab Code:
function flag = isTherePythagoreanTriple(a, b, c, d)
  if (c==sqrt(a^2+b^2))||(d==sqrt(a^2+b^2))||(d==sqrt(a^2+c^2))||(d==sqrt(b^2+c^2))

Sample Input and Output
 flag = isTherePythagoreanTriple(3,3.5,4,5)

flag =


>> flag = isTherePythagoreanTriple(3,3.7,4,5)

flag =


>> flag = isTherePythagoreanTriple(3,4,5,8)

flag =


>> flag = isTherePythagoreanTriple(1,2,3,4)

flag =

Click here for a video description.

Join us on Telegram: 
Join us on Facebook Group:

No comments

Popular Posts