## IsRightTriangle(x, y, z)

##### Last updated December 07, 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;
}
```

### Search CFLib.org

### Latest Additions

Raymond Camden added

QueryDeleteRows

November 04, 2017

Leigh added

nullPad

May 11, 2016

Raymond Camden added

stripHTML

May 10, 2016

Kevin Cotton added

date2ExcelDate

May 05, 2016

Raymond Camden added

CapFirst

April 25, 2016