Challenge 43

📐

Pythagorean Theorem

Open in Code Editor or Copy Instructions
...solutions at bottom of page...

Create a function to calculate the value of c in the Pythagorean Theorem

Examples:

pythagoras(3, 4) returns 5

pythagoras(1, 1) would return 1.41

Extension:

Pythagorean triplets are 3 numbers (a, b, c) that satisfy the Pythagorean equation, where all are integers - the 3, 4, 5 example above is one set of such triplets - create a new function IsPythagoreanTriplet to return whether values of a and b result in an integer value of c

Solutions

IGCSE 0478 / O-Level 2210 A-Level 9618