## IsRightTriangle(x, y, z)

##### Last updated December 7, 2001

**Version:** 1 |
**Requires:** CF5 |
**Library:** MathLib

**Description:**

Takes any three numbers corresponding to sides on a triangle and returns a boolean for whether or not the three sides can create a right triangle.
Order of numbers does not matter.

**Return Values:**

Returns a Boolean value.

**Example:**

```
<cfset x=4>
<cfset y=3>
<cfset z=5>
<CFOUTPUT>
Given x=4,y=3,and z=5<br>
Does this represent a right triangle?
<BR>
Answer: (#IsRightTriangle(x,y,z)#)
</CFOUTPUT>
```

**Parameters:**

Name | Description | Required |
---|---|---|

x | Length of one side of the triangle. | Yes |

y | Length of the second side of the triangle. | Yes |

z | Length of the third side of the triangle. | Yes |

**Full UDF Source: **

```
/**
* Takes any three numbers, checks to see whether they create a right triangle.
* Optimizations by Rob Brooks-Bilson (rbils@amkor.com) and Sierra Bufe (sierra@brighterfusion.com)
*
* @param x Length of one side of the triangle.
* @param y Length of the second side of the triangle.
* @param z Length of the third side of the triangle.
* @return Returns a Boolean value.
* @author Joshua Kay (josh@dataquix.com)
* @version 1, December 7, 2001
*/
function isRightTriangle(x,y,z){
// Sort the side lengths from smallest to largest
ArraySort(Arguments,"Numeric");
// Use the familiar Pythagorian theorem (a^2+B^2=C^2) to determine if this is a right triangle
Return (Arguments[1]^2 + Arguments[2]^2) EQ Arguments[3]^2;
}
```

blog comments powered by Disqus
### Search CFLib.org

### Latest Additions

Kevin Cotton added

date2ExcelDate

May 5, 2016

Raymond Camden added

CapFirst

April 25, 2016

Chris Wigginton added

loremIpsum

January 18, 2016

Gary Stanton added

calculateArrival...

November 19, 2015

Sebastiaan Naafs - van Dijk added

getDaysInQuarter

November 13, 2015